In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "how java deals with high concurrency". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to deal with high concurrency in java" can help you solve the problem.
High concurrency is a factor to be considered in the design of Internet system architecture, which, in popular terms, is an abbreviation for helping the system to handle the right requests. So for highly concurrent processing, there are the following points.
1. Optimize code to reduce waste of resources
First of all, in dealing with high concurrency, we need to start from the underlying foundation to avoid used new objects. We can try our best to use entity classes and singleton patterns. In the use and connection of tool classes and String, we can access and use StringBuffer or StringBuilder by using static methods. Of course, we also avoid using the wrong way to make conditional judgment, try not to use instanceof to make a conditional judgment, and use some efficient classes.
2.HTML static
When we access through a link, let the server transfer the request processing to the relative jsp page, and finally generate our data.
3. Separate the picture from the server
In one of our web servers, a picture consumes a lot, so we have to separate the picture from the web page on a different server, so that we can reduce the pressure on one of our servers and ensure that the system will not crash because of the picture problem.
4. Caching and batch delivery
We specifically use a caching mechanism of hibernate, in order to avoid getting data from the database every time, we will put the data accessed by users in memory and hard disk, and there are advanced distributed cache databases to use, which can increase the pressure resistance of one of our systems. Batch transmission is used in order not to receive too much information at the same time causing the system to crash and a loss of data.
5. Database cluster
Why do you want to cluster databases? When we are faced with a large number of user access, if only a single data can not quickly meet the demand, so we need to use this method.
6.DB optimization
First of all, when we design the database, it is very important to consider our later maintenance, and we also need to optimize the database, which will result if we do not do the optimization. our index maintenance will be greater than the efficiency of the index. And we should use the length and field appropriately in a field of the table so as not to affect one of our efficiency. There are also foreign keys, because there is an one-to-many relationship before the primary key and the foreign key, we need to set it reasonably because it can reduce our workload when we modify it. Finally, in the operation of the database, we should try to use prepareStatement and less Statement, because prepareStatement can be pre-compiled, and we can also set connection to readOnly, because Connection can connect to the library, or belongs to a heavyweight, we can use it directly. It is convenient for us to modify the default number of connections for the use of connection pooling.
The last point is to achieve a load balancing on the hardware.
This is the end of the introduction to "how java handles high concurrency". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.