DEV Community

Discussion on: Ask dev.to - struggle with flask+sqlalchemy

 
yev profile image
Yev • Edited

I measure on localhost without any pgbouncer, using pgbench, so no gevent and pgbouncer.

Thread Thread
 
rhymes profile image
rhymes

Let's recap because you're giving out information in small pieces and I'm having difficulties following what's happening:

  • you have a Flask/Flask-Alchemy/PostgreSQL app
  • this app runs on production with gunicorn and gevent
  • PostgreSQL is on a digital ocean
  • using pgbench from your localhost you're getting 5 RPS

There a few aspects to consider:

  • pgbench tests PostgreSQL, not your app. It also tells you transactions per second, not requests per second.
  • I'm not sure testing a remote PostgreSQL from your local machine is useful at all. Your app if deployed in the same network as PostgreSQL is not going to behave the same way anway. You should probably test it from the server that hosts the app
  • Are you running pgbench correctly? Benchmarking can introduce methodology errors. How many connections are you opening? Can you provide the command line you run the test with?
  • What happens to said PostgreSQL's memory when benchmarked?

Finally, have you tried to actually load test the production app? Or at least a copy of it. With tools like wrk for example.