Question

I am new to Gearman. I have following queries about optimized Gearman usages:

1) I think worker expects job as a "string". Can I send an Array or Hash as Job to worker? If not, is JSON the best Job format to send Array/Hash?

2) Can I attach rails application routes as worker for Job Server?

3) How do you check if a worker is running or not? Is there any administration tool available for Job Server and Worker stats?

4) Can I architect a ROR system, such that every request passes through Gearman job server? I have multiple applications using same database (some of them are iPhone app, Android app, website). My main goal is to access content using general API for all these applications. Or Gearman is more suitable for background processes?

Thanks.

Was it helpful?

Solution

I can't say I know anything about gearman, but I think I can answer to the first question.

When you want to pass objects to other methods, you need to serialize it in one way or another (this is almost always done when passing an object to another process). The "best" way to do this depends very much on what you want to send. JSON is one way, and is probably one of the smallest when it comes to transfer size. So, yes, you can use JSON to transfer hashes and arrays.

OTHER TIPS

Can I send an Array or Hash as Job to worker? If not, is JSON the best Job format to send Array/Hash?

Any type of string will do; however, JSON is great as it can be decoded easily and used to hydrate a model/entity.

Can I attach rails application routes as worker for Job Server?

I generally prefer to write stand-alone apps/scripts as workers. Ruby would be great for this. You might even write these as Thor scripts.

Is there any administration tool available for Job Server and Worker stats?

If you are comfortable with the shell, this may work for you: Any way to access Gearman administration?

Or Gearman is more suitable for background processes?

Yes, you will have better control if you use Gearman for stand-alone worker processes rather than try to run your entire application on top of it.

http://rack.rubyforge.org/

You may want to look at rack. This might get you where you want to go..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top