I currently run a couple of APIs using AWS Lambda: one is a traditional REST API, and the other is a WebSocket API. After reviewing my billing, I found that the costs of using WebSocket connections are significantly lower—roughly a quarter of the price for nearly the same number of requests. My question is, should I consider switching entirely to WebSocket for all my APIs? Are there any potential drawbacks to this approach? I've already set up the code to handle WebSocket connections using DynamoDB, so I'm wondering if this change makes financial sense or if it complicates things unnecessarily.
5 Answers
Have you looked into function URLs? They can be cheaper and faster for certain use cases, so it might be worth exploring those options too.
If your clients aren't browsers, you might find even cheaper options out there beyond just WebSockets. It pays to explore!
Are these savings really impactful for you, though? If you're only cutting a few cents each month, it might not justify complicating your application.
Switching to an HTTP API Gateway (V2) instead of the traditional REST API can save you even more—it's only $1 per million requests compared to the standard REST API. Definitely worth considering!
Remember, it's not just about choosing the cheapest option. You really need to weigh the features against your specific needs to find the best fit.

I didn’t realize the cost difference was that significant! Thanks for the tip, I’ll definitely check this out.