75 points · by AquiGorka · 5y ago · 47 comments
It's not clear when or how serialization happens.
Supposedly at some point the message I am sending to the worker is serialized, but this is not made clear to the user and it's not made clear when this happens.
A well-designed library would synchronously serialize the given object the moment it is passed in or let the user explicitly handle serialization. But I don't think that's what is happening here.
It appears messages are serialized only eventually and when they are finally sent off to a worker.
If you accidentally pass mutable state in here, you're in for a really confusing and fun debugging session. Likely it'll be a production-only bug too, because during development and testing you're unlikely to have the kind of message volume required to run into some modified-before-sent condition.
CTRL-F "mutable" and CTRL-F "serialize" gives no results, so I don't think the designers thought of this or thought to warn users.
I discovered through trial and error that returning image bytes directly would incur this ever increasing overhead, btu creating a binary buffer and returning that would not. It was just a pet weekend project, so I never did discover what was causing the issue.
Example: https://github.com/fendy3002/NodeLearn/blob/master/Redlock/s...
Might be easier and more flexible than asking the library to do it?
In deno, you can restrict what the code inside worker can do by passing a map of allowed permissions. I have built a simple privilege system on top of this to allow users different access level.
This is cheaper and faster than spinning up container.
https://github.com/domenic/worm-scraper/blob/master/lib/conv...
I've been using Tarn a bunch at work recently. We're doing some batch jobs, and I'm queuing work at each stage in Tarn.js pools. I created my own enqueue function that waits until the pool is less than a high-water mark in size before enqueueing. Then the pool has however many workers running.
Neither of these are off-thread pools. But they help a lot of for managing multiple async operations.
We have an api used for generating reports from mongo dB to csv, this let's the report process in the background leaving the report api to still handle requests.
It has support for worker threads + cron + human strings
We also have a worker thread blocked on a redis channel that acts as a queue.
The reason is: don’t wanna be boring from what I could glean.
I did something similar
https://github.com/tim-hub/pambdajs
but I haven't done the comparison on aws lambda yet
-- .on('end')
++ .once('end')Does it sound more exotic? Are these words less crowded?
You needn't use your real name, of course, but for HN to be a community, users need some identity for other users to relate to. Otherwise we may as well have no usernames and no community, and that would be a different kind of forum. https://hn.algolia.com/?query=community%20identity%20by:dang...
"Piscina" is a Portuguese word for "pool", by the way.
That's what they're called: https://en.wikipedia.org/wiki/Romance_languages
Portuguese is also a romance language, as Spanish or Italian. Piscina also means pool in Spanish by the way :)
In Portuguese they're only known for "Latin languages", which explains my question. ;-)