What’s the best and most cost-effective AWS service for running a Flask socket API?

0
4
Asked By RustyBiscuit42 On

I'm currently hosting a Flask API as a socket server on EC2 and I'm looking for some advice on the best AWS services to use for performance and cost efficiency. I've heard options like Lambda and ECS Fargate, but I'm not sure about the pros and cons of each. What would you recommend?

3 Answers

Answered By CuriousCat12 On

If you're less familiar with socket APIs, try using the WebSocket API Gateway. It could simplify things for you!

CodeMonkey99 -

Socket API means WebSocket, primarily for chat functionality.

Answered By MangoChutney27 On

Using EC2 or ECS is pretty much the same, but Fargate tends to be a bit pricier. To save some cash, consider reserved instances or a savings plan. If you're open to it, Lambda could be a solution, but it's not a walk in the park. You'd need a setup for database and session management, since you can't save anything persistently in Lambda. DynamoDB is a great option for session management, but large databases can be a pain since you can't just toss a MySQL database in Lambda and call it good.

TechieTim87 -

Lambda for persistent web sockets? That sounds sketchy.

SnappyCoder98 -

I have a separate MySQL database for another module that handles chat. Could I use that for the Flask API?

Answered By SocketMaster44 On

I’ve been running an Electron app connected via SocketIO for two years. Personally, I think EC2 or Lightsail work best for this. Just keep an eye on data size and egress costs, since exceeding certain limits can rack up expenses, but that threshold is usually pretty high.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.