I would like to hear your ideas about the idea: A separate base for each city. For example, let's say that a juzver comes to the site, in front of him is a window for choosing a city, he chooses a city and the info for the specific city should be shown. There was a thought to realize everything through

mysql connect 

but I work in Simpla CMS and there is a config connection to the database. How can I change configs in places depending on the user's choice?

  • That is, you have a base sharpened by the city? For each city has its own database? - Urmuz Tagizade
  • Yes, for each city its own database, a couple of them. - user197085
  • Do you insist on it? Or change your application logic is welcome? - Urmuz Tagizade
  • I am ready to listen to your suggestions - user197085
  • 2
    Compromise will be difficult. And if you need to add a city, create a new database, edit configs, or something else. then in the database there will probably be the same info for all cities, some reference books. Isn't it easier to keep one database and add the column "city" in the right tables - Mike

1 answer 1

It is a bad idea. You will either have to keep a separate set of users for each city, or tightly bind the user to the city. Otherwise, you will not be able to associate a user with his data located on another server. As a result, the simple operation of changing residence will turn into a hellish problem of migration in your backend-part of the site. The collection of statistics for all cities turns into a hell of a problem (and if this is an online store, as you write in the comments, you will need statistics). In addition, part of the scheme and data for each city you will be duplicated and it will have to somehow synchronize when updating.

If you want to achieve this with scaling, you will have an extremely uneven load - the overloaded databases of Moscow and St. Petersburg, and the rest of them idle.

Reading is best scaled by replication, writing by replication does not scale, but it can be split up by web services. Say, the catalog of goods in one database and one application, and comments and votes are implemented as a Web service that interacts with the site exclusively through JS. View counters began to create a perceptible load - take it to a separate Web service.