Comments (11)
I remember @iarna blogging about the fact that the gearman protocol allows multiple concurrent GRAB_JOB's even for a single connection.
I have understood that this is why the abraxas registerWorker has the maxJobs option to limit how many GRAB_JOB calls it should concurrently send. Haven't tested that in practice though.
If you are running in an event loop environment like node.js, you could also manually register several worker objects to run in parallel with their individual connections.
from abraxas.
Yes, that's right, that's exactly what maxJobs
does, check out https://github.com/iarna/abraxas/blob/master/example/load.js for an example of using it.
https://github.com/iarna/abraxas/blob/master/example/multicore.js has an example of using cluster
to spread work across CPU cores too.
from abraxas.
abraxas
supports concurrent JOB_ASSIGN_UNIQ
but not concurrent JOB_GRAB_UNIQ
The sequence for 2 maxJobs
is "grab-assign-grab-assign" instead of "grab-grab-assign-assign" and it harms worker performance on connections with large bandwidth-latency product.
For example,
Line 32 in ca73cf7
Should it be while
instead of if
?
from abraxas.
@nponeccop Ah, I see what you're saying.
It will totally handle multiple concurrent jobs on a single connection, because it PRE_SLEEP
s after accepting a job if there is room for more work. But that means that the concurrent job network flow looks like:
(assuming maxJobs = 2)
-> PRE_SLEEP
<- NOOP
-> GRAB_JOB_UNIQ
<- ASSIGN_JOB_UNIQ
-> PRE_SEEP
<- NOOP
-> GRAB_JOB_UNIQ
<- ASSIGN_JOB_UNIQ
-> WORK_COMPLETE
-> PRE_SLEEP
-> WORK_COMPLETE
Where as you would like:
-> PRE_SLEEP
<- NOOP
-> GRAB_JOB_UNIQ
-> GRAB_JOB_UNIQ
<- ASSIGN_JOB_UNIQ
<- ASSIGN_JOB_UNIQ
-> WORK_COMPLETE
-> PRE_SLEEP
-> WORK_COMPLETE
Am I understanding correctly?
from abraxas.
If we just change the if
to a while
, it looks like it would mostly be ideal. The only "issue" I would anticipate would be, if only one job was actually available, there would be an extraneous PRE_SLEEP
– and that's A) easy to guard and B) maybe not an issue?
-> PRE_SLEEP
<- NOOP
-> GRAB_JOB_UNIQ
-> GRAB_JOB_UNIQ
<- ASSIGN_JOB_UNIQ
<- NO_JOB
-> PRE_SLEEP
-> WORK_COMPLETE
-> PRE_SLEEP
from abraxas.
@iarna Yes you understand it correctly. However, waiting for NOOP
is a different issue #19 and could be fixed too if proved useful.
from abraxas.
If you wanted to put together PRs, I'd take them, if not, I will likely get to these, though I'm not sure on what timeline at the moment.
from abraxas.
@streamcode9 and I implemented a benchmark in Typescript:
And it shows that if if
is replaced by while
, and both the worker and the client are connected by WAN with 150 ms latency, the performance is increased twofold. I'll show few whisker charts later.
How do we clean the commit so it can be accepted as a PR? Now the repo contains Typescript type declarations. Is it ok? Or it's better to submit the compiled javascript version of the benchmark? Or should we submit the while
PR separately from the bench?
The change of the library code is minimal: worker.js
from abraxas.
oh wow, that's super cool... I'd prefer the PR by itself for just the code change if that's not too much work.
from abraxas.
Is there any reason why #24 isn't merged? It's just the code change
from abraxas.
I didn't see it =D
from abraxas.
Related Issues (20)
- Event Emitter Memory Leak HOT 2
- Update Docs HOT 2
- worker.js setClientId error HOT 3
- Tasks that throw errors remain 'Running' on Gearman server until worker is killed. HOT 18
- Immediate disconnect breaks worker's task.end HOT 6
- askForWork() performance over WAN HOT 3
- performance of workers limited by downlink bandwidth HOT 3
- Typo error
- Collaborators HOT 1
- Respect client.workers in Server job assignment HOT 1
- getStatus() throws an exception HOT 1
- task.error() gives ServerError: Job given in work result not found HOT 1
- Implementing graceful shutdown HOT 6
- connection-error event is not fired
- Autoreconnect don't work
- client seems to only connect to first server HOT 1
- Abraxas clients possibly leak memory HOT 6
- Proposed multiserver support HOT 10
- Client shutdown? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abraxas.