Hacker News new | past | comments | ask | show | jobs | submit login

Very interesting to see how just a single sync file call can destroy performance.

It makes perfect sense in hindsight, even though at the time it could be easy to think, "how much could this really hurt?"




"Our initial logging implementation accidentally included a synchronous call to write to disc."

You really want to avoid synchronous calls all of the time in node.js unless you are at a point in the app's life where it makes sense to block if necessary, such as on startup or shutdown.

Since this call was used in logging my guess is that the synchronous write call was called a lot and was easy to spot because of it. There are other places where calls like that would be harder to track down. As with any programming environment it is important to understand how things are working at least one abstraction level below the code you are writing.


You could think "how much could this really hurt?" But on the other hand, how much would it hurt to take the safer route and use the async function? I don't see why you would choose to use the sync function where it didn't belong. The documentation even warns against using the sync functions and states "synchronous versions will block the entire process until they complete--halting all connections."




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: