-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - Serverless Integration with a generic stateful endpoint. #504
Comments
@jamesvillarrubia I've also been thinking about this module in a stateless environment. As you mention, in an environment where instances are constantly being spun up/down, state doesn't really make much sense. It almost seems as though there should be some kind of proxy service that all of the stateless functions are pointing at. In this proxy service is where the circuit breaker lives. Of course, that doesn't help when the proxy is down. Functions, being inherently stateless, just can't maintain any information about the status of the remote endpoint - or at least not enough to be of much use. Not sure this helps much...
I can't speak for the team any more, but if you want to elaborate a bit on what you are thinking that would help. |
@lance hopping on this thread. |
@mlevkovsky Yes that's exactly what I was imagining. We just ported that same library you linked to firestore in GCP, but a generic storage API (with some adapters) would make me switch back to opossum, with all nice bells and whistles that it has. |
@mlevkovsky interesting concept. I would want to try and keep the main Opossum module as stateless as possible, so perhaps this is something that either plugins into opossum or that opossum can send its info too. We've done something similar with our opossum-promethesus module, https://github.com/nodeshift/opossum-prometheus . |
@lholmquist that makes sense. Thanks for linking me to that repo! much appreciated. @jamesvillarrubia Further more, I actually made an interesting discovery about lambda, that lets opossum works right out of the box. If you define something outside of the handlers in lambdas, AWS will “freeze” those resources between invocations (more information here). For an often used lambda, this means, that you can essentially, sort of be stateful. |
This issue is stale because it has been open 30 days with no activity. |
Landed on this thread with the same use-case outlined by @jamesvillarrubia. I am implementing a circuit breaker pattern in a serverless environment to control access to 3rd party APIs. I'd prefer not to roll my own implementation, as Opposum looks like a feature-rich solution that I'd prefer to use. The circuit-breaker lambda example provides one way this could be implemented in a serverless environment. While this is a great example of how this can be done, it tightly couples the persistence layer with the circuit breaker mechanism. Adding a persistence layer to this project seems outside of it's scope. I personally don't mind writing my own wrapper around opossum to persist state in a way that makes sense in my environment (e.g. DynamoDB, Redis, Postgres, etc). In order for this to be an option, Opposum would need to provide a way to initialize the internal state. I see we can get the circuit breaker status, which I could persist in my environment. However, I don't see a mechanism to re-initialize the same state. I haven't done a deep dive into this project yet, but does that functionality to initialize the internal state currently exist? |
It does not. I looked into this a couple of months ago but have not done anything to address it, since my work on this project is now mostly part-time, and I haven't had the time to do much more than look into what it would take. We do, of course, accept pull requests. |
@SethThomas fwiw, I think your approach sounds solid, and you are correct that a persistence layer is outside of the scope of opossum. Providing an API to support state initialization is the key. |
@SethThomas I know that AWS keeps some information preloaded to avoid the slow cold boot issue. |
@mlevkovsky This is a good thing to keep in mind, and certainly can help improve performance. However, be mindful that Lambda provides no guarantee how long the execution environment will stay "warm" between executions. If your application relies on CB state from a prior lambda execution, you'll probably want to manage the persistence yourself. |
@SethThomas yes 100% |
i've been working on an "import" for the stats that I'll create a PR for later today |
I started a draft PR here: #568 |
This issue is stale because it has been open 30 days with no activity. |
Closing this since this functionality was just released in 6.2.0, https://www.npmjs.com/package/opossum/v/6.2.0 |
Really interested in this library, but, as I understand it, it maintains state as property within the Class object. This is fine server-side, if I can share that Class object across multiple requests, but becomes a multiplicative problem in a high-concurrency, stateless environment like AWS Lambda.
Is there a pattern you recommend for serverless environments or sharing object state across containers that I'm not seeing in the docs?
If not, would that be a plugin/addition/alternative that the nodeshift team would be interested in?
The text was updated successfully, but these errors were encountered: