Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problems caused by gearman queue persistence

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to solve the problems caused by gearman queue persistence". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problems caused by gearman queue persistence".

The specific analysis is as follows:

1. Gearman creates Mysql persistence queues as follows:

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

Create database gearman

two。 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 it.

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

Use gearman; show tables

You can see that there is a "gearman_queue" table below.

In this way, gearman becomes a way of persistence.

2. After gearman is persisted with mysql, it will bring about the following problems:

1. Each task will be written to the database, which will lead to the loss of disk IO, and there is another possibility that the performance bottleneck of gearman is the performance problem caused by the database.

2. Mysql has a parameter of "wait_timeout", which is run on the mysql command line

Show variables like "timeout%"

You can see the value of wait_timeout, which defaults to 28800. That is, if a mysql connection does not respond for more than 28800s, it will be disconnected.

3. In the way of gearman persistence, if there is no response beyond the wait_timeouts of mysql, the connection to the database will be disconnected by mysql, and gearman currently has no mysql reconnection. As a result, it will result in the following error, and gearman must be restarted to work normally.

Gearman error:

ERROR 2014-04-01 02 mysql_stmt_execute failed:-> libgearman-server/plugins/queue/mysql/queue.cc:357ERROR 2014-04-01 02 mysql_stmt_execute failed 10 mysql_stmt_execute failed 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's timeout disconnection of mysql connection, you can increase the wait_timeout parameter of mysql.

Or, simply give up using mysql persistence.

Thank you for reading, the above is the content of "how to solve the problems caused by gearman queue persistence". After the study of this article, I believe you have a deeper understanding of how to solve the problems caused by gearman queue persistence, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report