+ 1
It is simple,
1. Sync : run the sync, when you are staring your server and needed to called one, e.g. loading a config file in the memory before server started listen to the port.
2. Aync : run the async one when one need to read file inside a request handler so it will not block other request from the client.
Note :-
Sync is faster than async in reading files, but blocking the main thread, so use it before using server starts listening to a port.
Q. Which one is better ?
Ans :- It depends on where you are using it, in a request handler, we need a non blocking async method so other clients don't have to wait for previous client response.
sync method are more faster but useful when executed once or before the server starts handling client requests
- 1
The async one isn't blocking the main thread. It appears like that, because you are choosing to wait. But sync one on the other hand will block the thread.
With the async process, you can keep doing stuff in the main thread. I don't know the specifics of your code. But, I would personally go with the async solution. Shoving everything down to the main thread makes it feel laggy and unresponsive.