question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using mock request/response instead of proxy

See original GitHub issue

Possible outcomes:

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:

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:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
brett-vendiacommented, Jan 5, 2021

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

1reaction
brettstackcommented, Jun 20, 2018

Thanks for the comparison @dougmoscrop. I’m going to stick with current implementation for now until we have a strong case for changing.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found