Using mock request/response instead of proxy
See original GitHub issuePossible outcomes:
- merging this project with https://github.com/dougmoscrop/serverless-http
- replacing the use of proxy in this project with mocked or stubbed request/response objects
- stay the course – having two approaches is valuable!
Considerations:
- maintainability
- ❌performance -> not worth it, performance difference is not significant enough
Maintainability
This can get pretty subjective. Not going to fill this in at this time.
Performance
This seems reasonably objective! Here’s some testing I did:
- using
loadtest
to call a deployed Lambda function after warmup: https://github.com/awslabs/aws-serverless-express/pull/116#issuecomment-382191862 - running the “lambda code” entirely locally (faked invocation of handler): https://github.com/awslabs/aws-serverless-express/pull/116#issuecomment-382197301
percentiles of ms for a complete request (res.json({ hello: 'world!' })
express app)
--serverless-http--
50 0.16584000000000287
90 0.2303940000000182
95 0.8473280000000045
99 9.287000000000006
100 9.287000000000006
--aws-serverless-express--
50 1.2586509999999862
90 1.9880190000000084
95 2.5715459999999837
99 15.208489999999983
100 15.208489999999983
You can see:
- serverless-http seems quite faster than aws-serverless-express when running locally
- performance varies so much in deployed Lambda that neither approach seems of any consequence (~2ms doesn’t matter when each request can vary by ~400 ms of jitter)
- there’s some kind of weird slow start locally that I’d like to investigate
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
[ Question ] How do you manipulate proxy response · Issue #97
Hi, I'm using Express 4, In normal way, I can do the following app.get('/v1/users/:username', function(request, response, ...
Read more >Mocking API requests and responses through Charles Proxy
You can enable or disable rewrites of request/response bodies, parameters, or status codes to be in place whenever you use the targeted ...
Read more >wiremock to mock public backend response - Stack Overflow
I want to use wiremock to mock reponses from the public backends. I was looking at something like. the app makes a request...
Read more >Fiddler In Action: Mocking And Manipulating API Behavior ...
In this five-part article series, you learn how to manipulate your API behavior with a local proxy server. So far, this series has...
Read more >Set up mock integrations in API Gateway - AWS Documentation
If you need them for your use case, you should consider using a Lambda integration instead. Using an integration request mapping template, you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @dougmoscrop, I’m going to go ahead and add in the mock request/response approach in v4. I was able to take your Request and Response classes and replace the local server pretty easily. I’ll add an attribution link to the top of these files 🙂
Going forward, Vendia plans on adding multi-cloud support. v4 was refactored to allow for multiple event sources (way back in May 2019 but never released), so I’m hoping it’ll mostly be a matter of detecting the incoming payload and mapping to the correct event source mapper (which is really just a request/response mapper) regardless of which cloud service it’s coming from.
Email me at brett@vendia.net. I’d love to get on a Zoom
Thanks for the comparison @dougmoscrop. I’m going to stick with current implementation for now until we have a strong case for changing.