Overview of gearman’s task distribution scheme under high CPU business scenario
Gearman was used by livejournal to do image resizing in those years. We also understand that image resizing is a high CPU operation. If you let the web site do this high CPU function, it may drag you down
For web applications, let's take a look at how gearman solves this problem. Its architecture diagram is similar to the following:
@H_ 502_ 7@
From the above figure, you should see that gearman is composed of three parts:
This is gearman's job server, which bridges the client and jobwork. Do you remember the mediator mode...
Gearman provides the client API for the client to call. The client only needs to throw a high CPU business function name to the job server, and then wait for the return execution result of the JObserver.
Gearman provides the work API to call the work client. The job server will distribute it to an appropriate work cluster for execution according to the load of the back-end work cluster, and wait for the results.
At this point, you should understand that it is essentially a distributed RPC call, and the most powerful thing is that client and work can be implemented in different languages.
At present, gearman's JObserver is implemented in three languages: C, Java and Perl. Since the C version of JObserver is the most active, the latest Version 1.1.1 is adopted here 17 version of gearand in CentOS
Install and deploy on.
@H_ 502_ 7@
You can use the official website http://gearman.org/getting-started/ Get started in for quick installation.
Basic dependency library installation and gearland Download
Then there is the routine/ Configure -- prefix = / usr / myapp / gearman & & make & & make install this process is super slow. You can go out and smoke,
A few years later, when you see this, even if the installation is successful... Congratulations.... At least it doesn't let you step on the interface that lacks various dependent packages.
When starting gearland, you can also use - D to start the background running mode. Add debug here to just look at the real-time debug information, as shown below: