1

I'm working on web project, where I use spring, mysql, hibernate and docker. There is no problem to make a design of relation db, it works.

How to verify the db's design is correct?

How to foresee the high-load for the project?

I know about the gatling load tests. I've got only a production environment. How to manage the production environment with such tests?

What's about hibernate, is there some overload of db?

Could you advise the proven books, about high load approaches for production?

0x01
  • 29
  • 1
  • Try posting a single question per post (as they are stated like here, they could be divided to 3/4 separate posts). First - design - I assume that you ask about if prod schema is 1to1 to the dev schema? Then if hibernate cannot create tables for missing entities by its own (and it shouldnt be able to) then you need to write additional tests/checks if new entities/relation exists. In most cases testing on prod env is a bad thing, unless you won't create any new record with them - ie only get requests when testing, so best would be to run them when the traffic is minimal. – itwasntme Mar 18 '20 at 00:37
  • The biggest "high-load" comes from a methods/endpoints that are being called most often or when they uses most of the server resources - when compared to other methods. Hibernate might add some overload, but only if configured (the connection and entities) badly, ie the entity fetches the list of related members even if later it doesn't access that list - here the idea of caching (there're few levels of it) comes as solution - most often called resources should be cached. – itwasntme Mar 18 '20 at 00:42
  • *"I know about the gatling load tests. I've got only a production environment. How to manage the production environment with such tests?"* - Just don't!! If you are serious, build a test environment. (Or take your production system offline for extended periods for testing ... and ignore your users' complaints.) – Stephen C Mar 18 '20 at 01:28
  • Thanks. I'll take into account your advice. – 0x01 Mar 18 '20 at 16:15

1 Answers1

2

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.
Andy Nghi
  • 56
  • 5