Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ØMQ (zeromq) isn't quite working #10

Open
remy opened this issue Feb 27, 2012 · 5 comments
Open

ØMQ (zeromq) isn't quite working #10

remy opened this issue Feb 27, 2012 · 5 comments

Comments

@remy
Copy link
Owner

remy commented Feb 27, 2012

TL;DR - please have a look at my zeromq setup - it's wrong and needs fixing - help me Obi-Wan....


I'm using zeromq to post off the job of parsing all the CSS in a url, and then once it's complete, it passes the message back to the the main app.js node process.

Ideally, lots of requests could come in, and I could be running 2-4 worker processes (node prefix.js) and requests would queue up, get processed, and returned to the correct waiting http client.

My problem (aside from having never used zeromq or any queuing system for that matter) is that the job is passed off to the worker, but because (I think) I have an odd one-to-one queue set up, the same job gets returned to all of the clients.

It's tricky to replicate, because you need concurrent request - but here's an example:

curl "http://cssprefix.com/check.json?http://remysharp.com"; \
curl "http://cssprefix.com/check.json?http://jsconsole.com"; \
curl "http://cssprefix.com/check.json?http://remote-tilt.com"

{"pass":true}
{"pass":false,"lint":{"type":"warning","line":834,"col":3,"message":"The property -ms-transition is compatible with -webkit-transition, -moz-transition, -o-transition and should be included as well.","evidence":"  -webkit-transition: opacity 200ms;\r","rule":{"id":"compatible-vendor-prefixes","name":"Require compatible vendor prefixes","desc":"Include all compatible vendor prefixes to reach a wider range of users.","browsers":"All"}}}
{"pass":false,"lint":{"type":"warning","line":834,"col":3,"message":"The property -ms-transition is compatible with -webkit-transition, -moz-transition, -o-transition and should be included as well.","evidence":"  -webkit-transition: opacity 200ms;\r","rule":{"id":"compatible-vendor-prefixes","name":"Require compatible vendor prefixes","desc":"Include all compatible vendor prefixes to reach a wider range of users.","browsers":"All"}}}

Note that the last two return checks are exactly the same, even though the CSS is different for all three sites - which says to me that the worker returned to two clients - hence the screw up.

I'd love for someone with experience to dive in an have a decent crack at getting the parent / worker set up correct - then we'll have a web service that doesn't blow up my machine when concurrent requests come in!

@hardyjohnson
Copy link

Not sure about the return issue, but is there a reason you wouldn't use valid URIs in your API (i.e. http://cssprefix.com/check.json?url=URLENCODEDURL)?

Thanks,
Hardy

@mathiasbynens
Copy link

I haven’t looked at the code, but this sounds like it could be a scoping issue.

@remy
Copy link
Owner Author

remy commented Feb 27, 2012

@hardyjohnson no - there's not. But it's still in development and the scaling issue already hit my server hard enough to take the thing out. So yeah, the url should be validated first because I end up with junk files in the job directory.

@mathiasbynens the jobs are passed back and forth via sockets, and only a single socket is setup (with workers listening and grabbing). I think it needs an intermediate process to join requests up to responses and pipe them back and forth correctly, but I'm not savvy enough with zeromq to know how to go about doing that (or even if it's correct).

@lennym
Copy link
Contributor

lennym commented Feb 28, 2012

I'm learning about ZMQ sockets as I went on this, but even with just binding on('message', ...) in app.js then I still wasn't even getting the messages I was expecting from the prefix worker. Changing the socket type to 'pair' seemed to emit all the events I would expect, and swapping the per-request bindings to 'message' for a single listener which emits job specific events seems to fix your issue.

@remy
Copy link
Owner Author

remy commented Feb 28, 2012

@lennym so send me a pull request! It's utterly new to me and I couldn't find any decent examples that I could get what I needed on the web (though the docs are superb, I needed the starting thread).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants