In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "what are the pools in the web technology stack". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the pools in the web technology stack"?
Connection pool
I believe that every programmer is no stranger. When we use a cache such as Redis or a database such as Mysql, we often need to configure connection pooling. I believe that every Java programmer has configured C3P0 or HikariCP connection pooling. Why do we need connection pooling? what are its benefits?
If there is no connection pool, what happens when we access the database? first of all, we need to establish a connection handle, establish a connection, which means a three-way handshake, which takes several milliseconds, and then, not everyone can access the database, the database also needs to verify the login account password, which takes 1 minute 2 milliseconds, and then the real data query It may have taken 1 minute 2 milliseconds, a 10 millisecond request, and maybe 80% of the time has been wasted.
Second, connection pooling can make the service more stable. For example, if the downstream database supports 1000 concurrency, but the business layer supports 10,000 concurrency, what may happen at this time? the 10,000 requests of the business layer request the database at the same time, exceeding the maximum load of the downstream system, isn't that killing the service? Connection pooling allows us to assign different connections to different services so that their total number does not exceed the maximum value of the system.
Object pool
Garbage collection is a big headache in the Java language, especially when FullGC always causes problems, not just in many Java languages. For example, if we develop a game, an example of a soldier object represents a soldier with a long gun, and the player may have to kill hundreds of soldiers in a game, then every time a soldier dies, we will cancel this instance, and every time a soldier refreshes, we will re-new an instance. As we all know, there is a price to apply for memory from the operating system. Maybe you are a stand-alone game. If it is a large online game, there are frequent fights among various players on the page. At this time, we'd better use object pool technology. When the soldier dies, it will be recycled instead of directly released, and the next time a new soldier appears, it will be directly reused.
Object pooling technology reduces the frequent application of memory from the operating system, especially large blocks of memory, we need to use object pooling technology to better optimize the use of memory and reduce the number of garbage collection, so as to make the program more optimized.
Thread pool
Similar to object pooling, we can understand that thread is also an object used by the operating system. In modern computer development, multithreading is very common and necessary, which can effectively take advantage of the characteristics of multiple cores of CPU, but the operating system creates threads and destroys them. Therefore, we can use pooling technology, but after the operating system runs a thread, it is not destroyed immediately. Instead, let the idle thread continue to wait for the new task to execute.
Memory pool
Memory pool, which may be used by C++ students more, the most representative is the Google development of TcMalloc and Facebook development of JeMalloc. In fact, Java development will also use memory pools, Java has some Unsafe methods, you can directly manage memory, in some middleware development, we will often use.
The larger role of the memory pool is to reduce memory fragmentation. What is memory fragmentation? Many students don't understand what memory fragmentation is. Let's give an example. We have a piece of wood that we want to use to make chairs, and if we don't plan the wood for each part of the chair and cut it off whatever we want, then in the end, the utilization rate of this wood will not be high. The same is true of memory, if each application is randomly allocated, it is easy to form a lot of memory fragments, and finally slow down the program.
At this point, I believe you have a deeper understanding of "what are the pools in the web technology stack?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.