Proxy API with Circuit Breaker on AWS lambda
Asked Answered
P

1

7

I'm building an API that will act as a proxy to n underlying API's that all do the same thing. It will use circuit breaker pattern to determine when one of the underlying API's is unavailable, therefore the proxy API will have state. One solution is to run the API on AWS lambda and store the circuit breaker state in AWS ElastiCache.

Is there another more cost effective solution that would not require me to run an 'always on' service like ElasticCache?

Prostration answered 20/7, 2017 at 8:21 Comment(5)
"n APIs that all do the same thing" sounds as if you are trying to re-invent the load balancer... so you might want to clarify what you are trying to accomplish, overall. Whose APIs are these n? Are they fungible? What is your course of action when the breaker trips? You could potentially be designing some ironic unreliability into your platform by tracking state in a stateless environment.Toil
The API's do the same thing (send email) but have different contracts so a load balancer isn't an option. Yes, ideally I would keep the solution stateless but I want the behaviour that circuit breaker provides so that I can detect when services go up and down and route traffic accordingly.Prostration
Okay, sending email is actually a pretty good (relatively rare) example of disparate-but-fungible APIs from different vendors. The question does require some thought, though, since (among other things) you also need to hand back a unique transaction identifier to your caller to identify each interaction for later tracking and troubleshooting of which target processed the message. It seems like mail would be best handled with store-and-forward rather than cut-through.Toil
I'm starting to look into similar pattern/architecture for AWS (not necessarily proxy only), and was wondering if/how you managed to implement the circuit breaker pattern in AWS API management. Did you use a lambda finally? Backed by DynamoDB? Or something else?Archon
Not sure I get the complete problem but if your are just looking for a storage which is not 'always on' then what about using AWS Systems Manager Parameter Store (docs.aws.amazon.com/systems-manager/latest/userguide/… ) and using it from Lambda.Leonidaleonidas
S
0

Probably what I would do is store some of the state in the lambda with a time code, which I would assume the time to be pretty short. Obviously this data is not guaranteed to be there for you (lambdas spin down and back up are going to be blank), so if it's not there, or greater than some time value that your solution is good with, go grab it from DynamoDB. DynamoDB is a cost effective solution, and fast on look ups by PK. But you'll always want to write any updates to DynamoDB.

I just saw this is 3 years old, so ˜\__(ツ)_/˜

Sandglass answered 7/8, 2020 at 20:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.