Today I went to interview a company doing e-commerce project , Ask as soon as you come up : How do you solve the problem of high concurrency ? It seems that the problem of high concurrency can not escape in the interview , Now write your own understanding , The understanding is very shallow , But I also hope to help you .
I think we can start from these aspects to answer this question :
first , Hardware level , The server uses more memory , Better hard disk . in consideration of money, This is certainly not the answer the interviewer wants to hear , But you can say a word .
second , Software level :
1. The application server is definitely the first to suffer , So we have one first niginx Balance responsibility , How many application servers are deployed in the background ,
Distribute requests evenly to each server , It is called cluster deployment ;
2. After cluster deployment , The pressure on the application server has been temporarily resisted , Now it's the database that's not going to work . At this time, we should consider the sub database and sub table ,
There is also the separation of reading and writing , Get all the write pressure to the main library master upper , The pressure of reading gets from the library slave. That is, sub database and sub table + Separation of reading and writing ;
3. If the traffic continues to expand , Scale out the database server , But also consider money The problem of , So it doesn't work . Then the cache server
start doing sth. , Be a cache cluster .
4. The previous cache cluster only solves the problem of reading , In fact, the pressure is still great , At this time, the message intermediate key will be introduced , Like all kinds of mq Something like that
Dongdong . Because in some businesses, many pieces of data are written at one time , It's all written right away, but it's not . for instance , Like after users pay , Pay first
The relevant data is stored , Other records are placed in mq in , When the system is idle, save it slowly .
In the final analysis, it is from the architectural level to answer this question , I think it will be better , Of course, that's the idea , It involves a lot of technical details , I was there too
Learning , We can only learn and understand by ourselves . be ashamed ! There is also a reminder of the interview friends , When you say these ideas , And then there's the question
Distributed dependent , Like how do you solve distributed problems session Inconsistent issues , Distributed transactions and so on . Good luck with your interview !
Technology