flask applications. What would be the best way to scale them please?
What do you mean with "scale"? Maybe you need to use load balancer and put your apps on different machines?
Maybe u don’t have enough cpu cores for your number of workers
This might be the issue. How many cores is considered 'normal' with large apps?
This is horizontal scaling, yes. This is a good direction to go too, later.
It depends on your RPS values. Check how many cores your server has and how many workers you use. It is in gunicorn docs btw
on one 1Ghz core Flask App that bcrypting string for 20 times can easily stand with 300 requests/sec But it will answer only 20req/sec. so... How many cores you need - depends on what is inside your app and how many users will make requests.
4 cores, worker 10, single db
Problem may be in your code that works with db.
yes, there's hundreds of db I read and that takes time basically
cool idea. I think it is time to refactor.
you can put DB on the other server inside internal network and transfer some counts to DB from App
Does this make the system faster ? right now I use everything inside one server;.
ofc it does :) Your CPU threads are highloading with your app and DB (queue is formed) When you divide DB and App for different servers - it could increase throughput on the App and DB. :)
Profile app, detect endpoints that take long time. Refactor code that is querying database. Use background tasks if it still takes too long.
Обсуждают сегодня