|
|
|
|
|
by dgllghr
2652 days ago
|
|
It seems to me that the benefit of Workers is that they run geographically near the user. If the Worker is calling a database that may or not be close to your user, what is the point? You are going to pay the latency cost either from the user to the Worker or the Worker to the DB. I realize that there are some advantages. The network between the Worker and a Google datacenter is probably much faster than the network from the user to the Worker. Also, Firestore in particular can be geographically replicated so that the database is closer to your user. But I'm not convinced that these benefits outweigh a more traditional (and more flexible) architecture. |
|
Think of all of the random conditionals that your http routes have; "is the client posting a correct data structure" or "is this a valid OAuth token" or "am I requesting something that I already have cached" or rate limiting or the list goes on and on.
All of that kind of stateless route level logic that may not need to hit a data store is a perfect candidate for an edge worker, because once you have that deployed, you can concentrate more on business logic within your main application.
For example: "I have a valid OAuth token, I have established my identity, now issue an S3 pre-sign request and forward the resulting URL to the browser to download a protected file". Doing that within a worker will absolutely speed up your user experience by a couple hundred milliseconds at least.