1. We can't foresee the high load of the project. We can monitor our system and predict the future load based on historical load.
- Spring Boot Actuator: to produce metrics data
- Prometheus: to gather your application’s metrics
- Grafana: for visualization of your metrics data.
To prevent the system crash because of high load or DDOS, you can use Guava RateLimiter.
2. For databases, you need to monitor slow queries to know if your DB design is correct. If a query is slow, you can use explain keyword to check if your query use index properly.
Enable query logging to general_log table:
mysql> SET GLOBAL general_log = 'ON';
mysql> SET global log_output = 'table';
Then query slow queries in the table:
SELECT * FROM mysql.general_log ORDER BY event_time DESC LIMIT 10
3. To make your app high load, there are 2 options:
- Most of the time, the bottleneck is in the database, you can split your database to multiple databases, for example users related tables will be in a separate database, order related tables will be in another database (https://microservices.io/patterns/data/database-per-service.html).
- For a very high load system, you should architect your system on the cloud using Google Kubernetes Engine or Amazon EKS.