gearman

Valid Architecture for a Message Queue & Worker System in PHP?

余生颓废 提交于 2019-12-04 02:17:14
I'm trying to wrap my head around the message queue model and jobs that I want to implement in a PHP app: My goal is to offload messages / data that needs to be sent to multiple third party APIs, so accessing them doesnt slow down the client. So sending the data to a message queue is ideal. I considered using just Gearman to hold the MQ/Jobs, but I wanted to use a Cloud Queue service like SQS or Rackspace Cloud Queues so i wouldnt have to manage the messages. Here's a diagram of what I think I should do: Questions: My workers, would be written in PHP they all have to be polling the cloud queue

Error conditions and retries in gearman?

淺唱寂寞╮ 提交于 2019-12-03 11:06:25
Can someone guide me on how gearman does retries when exceptions are thrown or when errors occur? I use the python gearman client in a Django app and my workers are initiated as a Django command. I read from this blog post that retries from error conditions are not straight forward and that it requires sys.exit from the worker side. Has this been fixed to retry perhaps with sendFail or sendException? Also does gearman support retries with exponentials algorithm – say if an SMTP failure happens its retries after 2,4,8,16 seconds etc? To my understanding, Gearman employs a very "it's not my

nagios/passive_check

给你一囗甜甜゛ 提交于 2019-12-03 10:45:44
术语 被监控机(MC:Monitor Client) 监控机 (MS:Monitor Server) 被动模式工作原理: 在被 MC 上面,使用nagios-plugins提供的插件,得出监数据,将数据发送到 MS 端,MS上面运行的daemon(常见的是nsca,或 nrdp,mod_gearman )用来接收这些数据,按照预定义的格式传递给nagios,nagios核心进程将会对数据进行处理(前台展示,警报)。 nsca 插件采用的是将检测结果写入外部命令文件,该文件是一个管道文件,也是nagios主程序的一个接口(用来接收监控数据),(ubuntu14.04 nagios 默认配置是 “/var/lib/nagios3/rw/nagios.cmd”); nrdp 插件除了将检测结果写入外部命令文件,还可以将检测结果直接写入到Nagios内核的spool目录,(ubuntu14.04 nagios 默认配置是 “/var/lib/nagios3/spool/checkresults”); mod_gearman 使用事件代理模式,会将结果注入nagios结果环形缓冲区数据结构中,不会被FIFO的IO限制 原理图 优缺点 优点:相比与主动模式,被动模式能很大程度地降低nagios负载 缺点:当监控的主机规模进一步扩大,会被"外部命令文件"I/O局限所拖累,(事件代理模式除外)

Gearman 基础 以及 Gearman 使用举例

拈花ヽ惹草 提交于 2019-12-03 10:21:51
<一> Gearman 基础 Gearman 是什么? Gearman 是一个分布式的任务分发框架。 Gearman 用来把请求委派给机器,提供通用的程序框架来将任务分发在机器运算。同时具备并行工作能力、负载均衡处理的能力,以及跨语言通信能力。 Client 的工作原理 主要分成三个部分Client、Job、Worker: client:负责建立一个工作,发送请求给Job Server,而Job Server 会去找合适的 Worker 去转发工作。 Job Server:了解Client 端的请求,并查看哪个机器可以处理这项请求,在系统里它通常是个Daemon。 Worker:Worker 通过Job Server 的分派,开始执行Client 端的工作。 关于Message Queue 执行 Message Queue 服务的 Job Server 可以是多台服务器组成,也就是分布式架构,在 Job Server 上执行 Worker 程序。 这些 Worker 程序会一直循环地等候,直到 Job Server 呼叫它执行工作。 Client 端发送出请求之后,会将需要的资料及动作记录在 Job Server 上,这时 Job Server 会查看是否有空闲并符合需求的 Worker。 在 Worker 结束工作后,会发送通知给 Job Server ,这时 Job

Supervisord adding multiple processes for PHP and Gearman

不问归期 提交于 2019-12-03 10:19:53
问题 I recently set up Ubuntu Natty with PHP5-FPM, Gearman, and Supervisor. I've edited my Supervisord config to run a Gearman worker. [program:gearman] command=/usr/bin/php php_gearman_worker.php numprocs=1 directory=/root/sandbox stdout_logfile=/root/sandbox/supervisord.log environment=GEARMAN_USER=gearman autostart=true autorestart=true user=gearman Here's the relevant info (showing only gearmand and php processes) when I lsof -i -P before I run supervisord: COMMAND PID USER FD TYPE DEVICE SIZE

Gearman gearadmin command line tool status output meaning

余生颓废 提交于 2019-12-03 09:16:40
问题 I am unable to find any documentation on the meaning of the gearadmin command line tool with the '--status' option. What is the meaning of the three numbers found after the worker function name ? For example, then I run this command: gearadmin --status I get the following output: worker-function-name 114 0 0 . I don't know the meaning of the three numbers after the 'worker-function-name'. I don't think it matters but I'm using gearman with the php extension and ubuntu 13.10 server. 回答1:

mysqludf_json将关系数据以JSON编码

泪湿孤枕 提交于 2019-12-03 09:07:27
1. 前言 sphinx2.1版本引入了json属性,该如何构建json格式数据呢?mysql触发器与gearman结合应用时,只能向gearman worker传递单一的字符串参数,如果要将mysql表中的某些列的数据传递给worker处理呢?这些问题,在我工作当中遇到过的,后面再一一整理出来与大家分享。那么,这样将数据以json格式编码呢,下面先介绍下lib_mysqludf_json,后续会使用到这个UDF。 lib_mysqludf_json UDF库函数将关系数据映射为JSON格式。 通常,数据库中的数据映射为JSON格式,是通过程序来转换的。比如,PHP的json扩展,将PHP数据结构转换为JSON,这通常是需要遍历整个结果集后来创建JSON格式。使用UDF来进行JSON编码更快。 2. 通常用法说明 JSON UDFs在设计时考虑到在大部分情况下,只有一个简单和直接的映射是必须的。因此,JSON UDFs尽量简单的映射,尽量少的开销。不过,也能产生更复杂的映射。 2.1 lib_mysqludf_json提供的功能有: 1). 可变长度的参数列表允许直接映射 在很多情况下, 需要映射行级别数据为JSON数组或JSON对象。可变参数列表允许单一方法调用来接受一个完整的项目,随后被映射为JSON结构。 2). 字符串数据的正确转义 字符串值映射到JSON字符串时

Gearman, ZF2, Doctrine2, MySQL, SQLSTATE[HY000]: General error: 2006 MySQL server has gone away

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I use ZF2, Doctrine2, MySQL, Gearman. When working Gearman periodically has an error: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away. I tried these steps to fix the problem: 1) I investigated MySQL queries. Queries haven't any problem. It's simple (without subqueries) and fast. For example, this is EXPLAIN of one of queries when MySQL server has gone away. +-------------+-------+-------+-----------------------+-----------------------+---------+-------+------+ | select_type | table | type | possible_keys | key | key

Any Gearman tutorial? [closed]

我是研究僧i 提交于 2019-12-03 06:02:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am looking for a comprehensive Gearman tutorial (preferably with the PHP API). I am trying to understand the flow of the process. I set the daemon running, create clients and workers, but how do I handle them with Gearman (like add/remove workers etc.)? 回答1: For managing workers with PHP, I suggest my

Gearman with multiple servers and php workers

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm having a problem with gearman workers running on multiple servers which i can't seem to solve. The problem occurs when a worker server is taken offline, rather than the worker process being cancelled, and causes all other worker processes to error and fail. Example with just 1 client and 2 workers - Client: $client = new GearmanClient (); $client -> addServer ( '192.168.1.200' ); $client -> addServer ( '192.168.1.201' ); $job = $client -> do ( 'generate_tile' , serialize ( $arrData )); Worker: $worker = new GearmanWorker ();