Add Fastly session-reuse to WSGI HTTP handler, and demo it in game-of-life.#17
Conversation
…-life. Implementation is ugly as sin due to the early state of Python WIT bindings, but the user-facing API should be fine.
`sys` is no longer needed to pull in shims. `noqa`s don’t seem to be needed either.
posborne
left a comment
There was a problem hiding this comment.
I just noticed that I failed to submit the review I started on this, apologies!
Generally I think things look good -- it would be awesome to be able to showcase the actual timing improvement of reusable sessions, but I guess I'm not surprised to see much difference given that the component-init bits used by componentize-py are doing what they ought to do.
| body, | ||
| self.wsgi_app, | ||
| handle_errors=self.handle_errors, | ||
| ) |
There was a problem hiding this comment.
Not critical and possibly better left outside the SDK (or configurable), but I could see it potentially making sense to use intra-request periods as being good times to force gc with an otherwise relaxed gc policy to avoid it being hit while processing a request in most cases.
There was a problem hiding this comment.
That's a neat idea. We could make it so there's a pluggable callback that we call inter-request, and you can take whatever breaths you need therein. A GC-nudging one could be the default or a publicly available one.
| self, | ||
| wsgi_app: Callable, | ||
| handle_errors: bool = False, | ||
| reuse_sessions_for_ms: int = 0, |
There was a problem hiding this comment.
We should rename this to reuse_sandboxes_for_ms, to align with Compute eg. https://github.com/fastly/ExecuteD/pull/5981.
There was a problem hiding this comment.
Ha, I got the timing exactly wrong! Will do.
Implementation is ugly as sin due to the early state of Python WIT bindings, but the user-facing API should be fine.
Interestingly, it doesn't make any speed difference on my local machine, but maybe it would in prod.