Perl gearman server/client 1.10 released

50 views
Skip to first unread message

dormando

unread,
Oct 5, 2009, 2:46:27 AM10/5/09
to gea...@googlegroups.com
Yo,

http://search.cpan.org/dist/Gearman-Server/
http://search.cpan.org/dist/Gearman/

Many bugfixes, many small changes. Mainly of note are a bunch of
algorithmic improvements and the introduction of some tunables.

--accept=10
... number of new connections to accept per loop. Used to be 1 (oops), now
allows accepting new connections a lot faster. 10 is a sensible default.

--wakeup=3
A bit of back story... When a new job is submitted to gearman, *all*
workers which are in an *idle* state, and have registered for a job, are
woken up. They then race to fetch a new job, and the fastest server gets
it. If you have many many idle workers, say at night, or you need them for
bursts of traffic, or if you're just scaling... This can suck. Each job
submission will cause a *lot* of network chatter, waste a bulk of CPU
cycles.

The new default is to wake up only 3 servers. A setting of 1 is probably
just fine as well, and a value of -1 means old behavior.

--wakeup-delay=
... a complement to the above change. If a job is submitted, you wake up
1-3 random workers, and they don't pull your job, after 100 milliseconds
(default) all sleepers are woken up. This effectively gives you two
tunables to slide on how much you want gearman to guarantee latency over
throughput.

To further complement these, the algorithm for worker/server selection has
been tuned. When a worker is woken up, it now checks back against the
server that woke it up, instead of all of them. From the server
perspective, workers which finish work are put are the top of the list for
further work. This means that workers now have a rough affinity for a
particular server, and there's less unnecessary server-pinging from a
particular worker.

This improves scalability a *lot* and reduces the network chatter to
almost nothing. To round out completeness for these changes, if a worker
has not gotten any work in a while (about a minute) it will wake up and
ping all servers again. Hopefully fixing any dead connections and finding
more work.

There're also new text commands for inspecting jobs in flight.

We've used these changes to expand the number of gearmands we run while
reducing the amount of CPU usage on gearmand overall by ... most of it.
I've been running a load test with a single gearmand over 500 workers and
several thousand parallel-syncronous jobs per second. Gearmand's only
using a few % CPU.

-Dormando

Eric Day

unread,
Oct 5, 2009, 2:57:26 AM10/5/09
to gea...@googlegroups.com
Hi!

This is awesome, good to see the new Perl versions. :) I'll work on
getting the algorithmic changes into the C server as well.

-Eric

dormando

unread,
Oct 5, 2009, 3:15:56 AM10/5/09
to gea...@googlegroups.com
Thanks :)

I made a mistake in forgetting to note that hachi wrote most of the code
for this release. Thanks to Adam/Yann/etc as well. I worked on the
algorithm with hachi and did a lot of testing + a few small commits.

-Dormando

Pedro Melo

unread,
Oct 8, 2009, 4:40:49 PM10/8/09
to gea...@googlegroups.com
Hi,

On 2009/10/05, at 07:46, dormando wrote:

> http://search.cpan.org/dist/Gearman-Server/
> http://search.cpan.org/dist/Gearman/

These are great, specially the server.

Would you accept a patch to support both Danga::Socket and AnyEvent as
the I/O loop?

The reason is simple: Danga::Socket depends on Sys::Syscall and that
module is fails to install on certain platforms.

On the other hand, AnyEvent fallbacks to the pure perl I/O loop based
on select or poll, but can also use libev, the C-based library that
supports (like Danga::Socket) epoll and kqueue.

Also, if AnyEvent is supported, its easier to experiment with new
listeners (HTTP or even XMPP) given that we already have solid HTTP
and XMPP components built on top of AnyEvent.

Best regards,

Yann Kerherve

unread,
Oct 8, 2009, 4:51:51 PM10/8/09
to gea...@googlegroups.com
On Thu, Oct 8, 2009 at 13:40, Pedro Melo <me...@simplicidade.org> wrote:
>
> Hi,
>
> On 2009/10/05, at 07:46, dormando wrote:
>
>> http://search.cpan.org/dist/Gearman-Server/
>> http://search.cpan.org/dist/Gearman/
>
> These are great, specially the server.
>
> Would you accept a patch to support both Danga::Socket and AnyEvent as the
> I/O loop?

You might want to give a try to Mart's experimental module:
http://github.com/apparentlymart/libdanga-socket-anyevent-perl

Yann

Pedro Melo

unread,
Oct 9, 2009, 7:53:51 AM10/9/09
to gea...@googlegroups.com
Hi,

I knew that module, but I didn't though about using it here. I'll try
it.

On the other hand, I do believe that supporting AnyEvent directly
would be a better option. The API is much simpler.

Thanks,

dormando

unread,
Oct 15, 2009, 1:04:40 AM10/15/09
to gea...@googlegroups.com

How big of a patch would it be? If we're going to realistically swap out
the base of the thing we'll require a fair amount of bake-in and testing.

I haven't actually played with AnyEvent myself yet, but it looks pretty
rad. If you're willing to do a patch and provide some benchmarks to prove
there isn't a speed regression, we could take it.

-Dormando

Pedro Melo

unread,
Oct 15, 2009, 3:47:48 AM10/15/09
to gea...@googlegroups.com
Hi,

Ok, I'll start a branch and see how it goes.

Thanks,

jza...@gmail.com

unread,
Oct 15, 2009, 10:11:46 AM10/15/09
to gearman
I recently starting AnyEvent for another project and can confirm its
radness. :-)

Jeremy

On Oct 14, 10:04 pm, dormando <dorma...@rydia.net> wrote:
> > On 2009/10/08, at 21:51, Yann Kerherve wrote:
Reply all
Reply to author
Forward
0 new messages