Problems caused by Gearman queue persistence and solutions _linux shell

Source: Internet
Author: User
Tags create database mysql command line

This paper briefly introduces the method of Gearman using MySQL, and some problems caused by it, the detailed analysis is as follows:

First, Gearman create a MySQL persistence queue in the following ways:

1. Log into the MySQL command line and run:

Create Database Gearman; 

2. Start Gearman, order as follows:

/usr/local/gearman/sbin/gearmand-p 4730-l 0.0.0.0--log-file=/tmp/gearmand-4730.log--pid-file=/tmp/ Gearmand-4730.pid-q MySQL--mysql-host=localhost--mysql-user=root--mysql-db=gearman--verbose debug-d 

Specific parameters, according to their own server situation to modify the line.

3. Log in again to the MySQL command line and execute:

Use Gearman; 
Show tables; 

You can see a table with a "gearman_queue" below it.

In this way, the Gearman becomes a persistent mode.

Second, Gearman with MySQL after the persistence, will bring some of the following problems:

1. Each task is written to the database, which can lead to loss of disk IO, and a gearman performance bottleneck that is caused by a database performance problem.

2. MySQL has a "wait_timeout" parameter, running in the MySQL command line

Show variables like "%timeout%"; 

You can see the value of Wait_timeout, which defaults to 28800. In other words, if a MySQL connection, more than 28800s without any response, will be disconnected.

3. Gearman persistent Way, if more than MySQL wait_timeouts time without any response, and the database connection will be MySQL disconnected , and Gearman is currently no MySQL reconnect, the result is, Causes the following error, you must restart Gearman to work again.

Gearman Error:

ERROR 2014-04-01 02:10:02.897899 [proc] Mysql_stmt_execute failed:-> libgearman-server/plugins/queue/mysql/ queue.cc:357
ERROR 2014-04-01 02:10:02.897910 [proc] gearman_server_job_add Gearman_server_run_command (QUEUE_ ERROR)-> libgearman-server/server.cc:301

Therefore, the disadvantages of Gearman persistence is obvious, in this way, to avoid gearman MySQL connection Timeout Disconnect, you can change the MySQL wait_timeout parameters large .

Or, simply give up the persistent way of using MySQL.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.