Smart Placement
I have three Workers apps (2 SSR/fullstack; 1 SPA) which connect to a Worker "service" that makes the API requests to the external services they need. The service is a WorkerEntrypoint and the app Workers connect to it via Service Bindings and make RPC calls to it and it calls the API endpoints.
The users are mostly in South/East Africa but the origin servers are in Germany/Ireland. The reason I did the architecture this way was thinking that by enabling Smart Placement on the service it'd be moved close to the origins while the apps ran on the Workers near the users in Africa (or the US while we're developing it).
However, the dashboard says "Your Worker has not received enough requests to make a placement decision". Production (with no real users) has gotten 455k requests in the last month. Dev (with US traffic from us developers) has 680k+ in the last moth. What's "enough"?
Is there anything I can do to debug this further or encourage/ensure the service worker is running close to the origin servers it's talking to?
1 Reply
Re-reading the docs, I now see two important pieces of information.
Smart Placement only considers candidate locations where the Worker has previously run, since the estimated request duration in each candidate location is based on historical data from the Worker running in that location. This means that Smart Placement cannot run the Worker in a location that it does not normally receive traffic from.We don't typically get traffic from, say, Germany or anywhere in the EU, so it won't run the worker there even if that it closer/faster to the origin endpoints Probably most important:
Smart Placement only affects the execution of fetch event handlers. Smart Placement does not affect the execution of RPC methods or named entrypoints. Workers without a fetch event handler will be ignored by Smart Placement. For Workers with both fetch and non-fetch event handlers, Smart Placement will only affect the execution of the fetch event handler.As I wrote, "the service is a WorkerEntrypoint". It has no fetch handler. All the interactions with it are via RPC methods. Each of those makes it ineligible for Smart Placement ðŸ˜