gearman到底是什么-gearman官网片段翻译



Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages. It can be used in a variety of applications, from high-availability web sites to the transport of database replication events. In other words, it is the nervous system for how distributed processing communicates. A few strong points about Gearma

Gearman提供一个普适的应用框架来把你的工做转到其他机器上去,或者是转到适合做这个工作的机器上去。它允许你并行工作,负载均衡,并且可以跨语言调用,它能被很多的应用使用,从高可用网站到传输数据库复制事件。换句话说,它是处理如何分配运算和沟通的神经系统。以下是gearman的一些特点

  • Open Source It’s free! (in both meanings of the word) Gearman has an active open source community that is easy to get involved with if you need help or want to contribute. Worried about licensing? Gearman is BSD.
开源:免费、自由,开源社区、方便,BSD协议
  • Multi-language - There are interfaces for a number of languages, and this list is growing. You also have the option to write heterogeneous applications with clients submitting work in one language and workers performing that work in another.
多语言:目前已经支持了很多种语言,并且支持的语言数在不断增加,ni你也可以帮助我们增加
  • Flexible - You are not tied to any specific design pattern. You can quickly put together distributed applications using any model you choose, one of those options being Map/Reduce.
弹性:你不需要呗任何设计格式束缚,你可选择你喜欢的任意模型快速的把许多贡献的应用放在一起,比如说map/reduce模型 
  • Fast - Gearman has a simple protocol and interface with an optimized, and threaded, server written in C/C++ to minimize your application overhead.
快速:gearman使用优化过的多线程的简单的协议和接口,服务端使用C++编写让程序更小
  • Embeddable - Since Gearman is fast and lightweight, it is great for applications of all sizes. It is also easy to introduce into existing applications with minimal overhead.
可内嵌:因为gearman快捷轻量,所以它适合任何大小的应用,它也容易集成到现有的应用中去
  • No single point of failure - Gearman can not only help scale systems, but can do it in a fault tolerant way.
没有单点失败:gearman不仅可以帮助ti调整系统规模,也可以z做容错
  • No limits on message size - Gearman supports single messages up to 4gig in size. Need to do something bigger? No problem Gearman can chunk messages.
没有消息大小的限制:Gearman支持单个消息4GB,还想大的话gearman还支持chunk messages(大块的消息).
  • Worried about scaling? - Don’t worry about it with Gearman. Craig’s List, Tumblr, Yelp, Etsy,… discover what others have known for years.
担心扩展性?当你使用Gearman的时候不要担心,Craig’s List, Tumblr, Yelp, Etsy等这些网站已经使用了几年了




How Is Gearman Useful?
为什么Gearman这么有用?
The reverse example above seems like a lot of work to run a function, but there are a number of ways this can be useful. The simplest answer is that you can use Gearman as an interface between a client and a worker written in different languages. If you want your PHP web application to call a function written in C, you could use the PHP client API with the C worker API, and stick a job server in the middle. Of course, there are more efficient ways of doing this (like writing a PHP extension in C), but you may want a PHP client and a Python worker, or perhaps a MySQL client and a Perl worker. You can mix and match any of the supported language interfaces easily, you just need all applications to be able to understand the workload being sent. Is your favorite language not supported yet? Get involved with the project, it’s probably fairly easy for either you or one of the existing Gearman developers to put a language wrapper on top of the C library.

上面那个逆转文字的实例看起来是费了很大力气才能执行一个函数,但是这样做有各种各样的好处。最简单的例子就是你可以用gearman作为接口,然后Client和Worker就可以使用不同的语言来编写了。(后面都是在解释用两种语言 或以上,会有很多需求场景,如果没有你要的语言还可以贡献)

The next way that Gearman can be useful is to put the worker code on a separate machine (or cluster of machines) that are better suited to do the work. Say your PHP web application wants to do image conversion, but this is too much processing to run it on the web server machines. You could instead ship the image off to a separate set of worker machines to do the conversion, this way the load does not impact the performance of your web server and other PHP scripts. By doing this, you also get a natural form of load balancing since the job server only sends new jobs to idle workers. If all the workers running on a given machine are busy, you don’t need to worry about new jobs being sent there. This makes scale-out with multi-core servers quite simple: do you have 16 cores on a worker machine? Start up 16 instances of your worker (or perhaps more if they are not CPU bound). It is also seamless to add new machines to expand your worker pool, just boot them up, install the worker code, and have them connect to the existing job server.

另一个使用Gearman的场景就是把worker的代码放在不同的机器,做他们更适合做的工作,比如图片转换的场景一般意味着要消耗web服务的机器运算,用gearman就可以把图片传递给其他的机器来处理,而且通过gearman的均衡能力任务只会派发给空闲的机器,不会产生很忙的Worker还继续接任务的情况(后面内容是按核心数部署worker池等)

Now you’re probably asking what if the job server dies? You are able to run multiple job servers and have the clients and workers connect to the first available job server they are configured with. This way if one job server dies, clients and workers automatically fail over to another job server. You probably don’t want to run too many job servers, but having two or three is a good idea for redundancy. The diagram to the left shows how a simple Gearman cluster may look.

现在你该问了,如果job server(协调调度任务的gearman)挂掉了怎么办?你可以运行多个jobserver,让client连接到第一个jobserver上,这样如果第一个挂掉了他们就能转到第二个jobserver上。 两到三个jobserver是比较好的

From here, you can scale out your clients and workers as needed. The job servers can easily handle having hundreds of clients and workers connected at once. You can draw your own physical (or virtual) machine lines where capacity allows, potentially distributing load to any number of machines. For more details on specific uses and installations, see the section on  examples.
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值