<>1 Why do interviewers like to ask such questions ?

* Because everyone has this requirement in recruitment .

So skilled people , Internet companies are definitely responsible for over concurrency modules , The capture offer It's too simple . Unfortunately, most junior engineers don't even want to write high concurrency code !
Facing the specific complex and high concurrency business scenarios , The architecture must not be simple , It doesn't mean just one redis cache , Use one mq Asynchronous peak shaving is done ! The real one is many times more complicated .

If the interviewer asks you how to design a high concurrency system ?
That's mostly because you didn't actually work on concurrent systems . There's nothing special about your resume , So I'll ask you , How to design a high concurrency system ?
The essence is to see if you've studied it yourself , Is there a certain technical reserve .

It's best to recruit someone with real high concurrency experience , However, it is well known that there is a lack of such medium and advanced development in China . Therefore, we should take the second place , Take one that you've studied at least , It's better than nothing .

Don't talk much , Start dry goods export , How to answer the question !

<>2 system ( service ) split

Make a system ( service ) Split into multiple subsystems ( service ). Each system is connected to a database , There was only one library , There are multiple databases now , The most easy to do anti high concurrency .

<>3 cache

High concurrency scenarios , Most of them read more and write less , You can write a copy in both the database and the cache , Then read a lot of cache .

and Redis Tens of thousands of concurrent single machine , All systems have caching middleware . So consider it in your project , Let the read scenario that hosts the primary request , Use cache to resist it .

<>4 Message queuing

High concurrency write scenarios may still occur ( Second kill scene ). That's going to screw up your system ,11.11 Dudeka , If you use it Redis It must not be written , It's a cache , Data is always available LRU, The data format is simple , There is no transaction support .
So use it MySQL It still needs to be used MySQL. how ?

use MQ! Large number of write requests poured in MQ, Take your time in line , Write slowly after consumption in the back system , Control in MySQL Bearing range of .
So consider your project , Those writing scenes , use MQ Asynchronous write , Improve concurrency .MQ Single machine can resist tens of thousands of concurrency ok.

<>5 Sub database and sub table

Maybe to the last database tier , High concurrency is inevitable .
Then split a database into multiple libraries , Multiple libraries to resist higher concurrency .
Split a table into multiple tables , Keep the amount of data in each table a little less , increase SQL performance .

<>6 Separation of reading and writing

The database may also read more than write less , It's not necessary to have all requests in one library , We can have a master-slave architecture , Master database write , Read from library , Separate reading and writing . When there is too much reading flow , You can also add more slaves .

<>7 Elasticsearch

ES Distributed , Expandable , Distributed natural support with high concurrency , Because it can expand the capacity and add machines to resist higher concurrency .
Some simple queries , Operation of statistics class , Consider using ES load bearing , There are also some full-text search class operations , You can also consider using ES.

<> summary

You're really a little better , It's not about understanding technology , Or know what a high concurrency system should look like .
In fact, in really complex business systems , High concurrency is much more complex than it is said to be dozens to hundreds of times .

It needs to be considered , Which need sub database and sub table , Which do not need sub database and sub table , How about single database and single table and sub database and sub table join, What data should be put into the cache , What data can be put to resist high concurrency requests , You need to complete the analysis of a complex business system , And then gradually add the transformation of high concurrency system architecture , This process must be complicated .
Once you do it once , Done. , It will be very popular in this market .

What the company really values , It doesn't mean that you have some basic architecture knowledge related to high concurrency , Some of the technologies in the architecture ,RocketMQ,Kafka,Redis,Elasticsearch, High concurrency , Second class talent .
For a complex distributed system with hundreds of thousands of lines of code , Step by step architecture , People who design and practice overly concurrent architectures , This experience is invaluable !

Technology