I created a SaaS product. I am using PHP 8.3 with a MySQL 8.0 database. Locally this is very fast! No frameworks etc are used. Production runs on Azure. I have the following setup on Azure:
Database
Azure Database for MySQL flexible server
- Burstable, B1s, 1 vCores, 1 GiB RAM, 20 GiB storage
- MySQL version 8
Cost is about 20 euros/month.
App service
Azure Web App
Basic B1, 100 ACU/vCPU, 1 vCPU, 1.75 memory (GB), 10 GB storage
OS: Linux
Cost is about 10 euros/month
the problem I am experiencing is that initially when a random user goes to my website and perfoms an action where a DB query is needed. The database is VERY slow at first. It could be anywhere from 3-10 seconds! After this 'warm-up' every new user that goes to the website doens't have any delays and the DB queries are very fast. Let's say 30-60 minutes pass and there was no activity on the website and a new user goed to the website, it's very slow again. This is NOT something I want. What do I have to do to remove this 'warm-up'?
One would say that a database for ~20 euros/month would perform better. I've had cheaper MySQL databases that performed better..
Notes:
- Web App is set to 'Always ON'
- My DB is VERY small and perfectly optimized, ~5 tables, ~100 records
- My 'innodb_buffer_pool_dump_at_shutdown' is set to ON
- My 'innodb_buffer_pool_load_at_startup' is set to ON
- My 'innodb_buffer_pool_size' is 134217728 bytes (~128 mb)
- MySql and App service both run in a vnet
- MySql and App service both use ssl
- Everything I have is in the same region (West Europe) just like my audience