Gearman MySQL Persistence

Source: Internet
Author: User
Tags mysql command line

Gearman create a MySQL persistence queue in the following ways:

1. Log in to the MySQL command line and run:

Create Database Gearman;

2. Start Gearman with the following command:

/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 conditions to modify the line.

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

Use gearman;show tables;

You can see a more "gearman_queue" table below.

In this way, the Gearman becomes a persistent way.

=============================================================================

After Gearman is persisted with MySQL, it will actually bring some problems.

1. Each task is written to the database, which leads to loss of disk IO, and one more possibility of gearman performance bottleneck, which is the performance problem caused by the database.

2. MySQL has a "wait_timeout" parameter that runs on the MySQL command line

Show variables like "%timeout%";

You can see the value of Wait_timeout, which is 28800 by default. That is, if a MySQL connection is more than 28800s without any response, it will be disconnected.

3. Gearman persistent Way, if more than the MySQL wait_timeouts time does not have any response, and the database connection will be disconnected by MySQL, and Gearman currently does not have MySQL reconnect, the result is, will cause the following error, Gearman must be restarted to re-operate.

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 disadvantage of Gearman persistence method is obvious, in this way, to avoid gearman to MySQL connection timeout, you can change the MySQL wait_timeout parameters.

Or, simply discard the persistence mode with MySQL.

http://www.ttlsa.com/gearman/gearman-mysql/

http://huoding.com/2012/10/30/196

Http://www.linuxeye.com/database/mysql-replication-to-redis-by-gearman.html

Gearman MySQL Persistence

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.