Initial impression of high concurrent programming

[Foreword]
  The future technical direction should be programming in large data volume and high concurrency scenarios, respectively corresponding to the storage query calculation of large amounts of data, and multi-threaded processing of ultra-high requests. This is the future direction of technical development. Of course, on the premise that the basic business can be completed, add, delete, modify and check data conversion SSM. Now the number of users of the project has increased, and it often occurs. It has been tested well in the company. Once it is released to the live network, various performance bottlenecks will occur, request timeouts, database connection timeouts, and even component crashes. Therefore, it is not only high-concurrency programming, but also testing in high-concurrency scenarios. For example, companies are basically functional tests, and there are few performance tests. If the tests are insufficient, problems will definitely occur.
  Well, let's stop talking nonsense, and record the learning experience.
[Text]
  High concurrency mainly includes: thread safety, thread closure, thread scheduling, synchronization container, concurrent container, AQS, JUC, etc.
  Generally, high concurrency problems are solved, and the main methods are: expansion, cache, queue, split, service degradation and
  Let's talk about the application of these in the project team, such as fuse, database cutting, sub-database and sub-table, etc. For capacity expansion, basically all components have experienced stand-alone-double-click-cluster; caching is mainly used for redis + persistence in the user order relationship; service downgrade is to add thread locks to the interface, with a frequency of 1tips; sub-database sub-table, basic There will be a concept of a user library system library. The user table, a large table with hundreds of W, is divided into 10 tables according to the first letter of the ID.
  High concurrency is nothing more than to ensure that your threads are safe, and there will be no inconsistency between the data transmitted by the thread and the last storage.
  Thread safety mainly includes:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324805451&siteId=291194637