Worker -> Durable Object fetch RPC call performance in Rust
Hello I'm running into some performance issues using Workers and Durable Objects. I'm using rust. I would like some help improving performance.
I have a worker that clients connect to. The Worker then passes the request through to a Durable Object (DO) which establishes a websocket connection and sends over a somewhat large batch of data.
I measured a measures for a cold start of the durable object.
* the total time for the Durable Object "fetch" method to complete
do_t
* total time for the worker to call the durable object fetch worker_t
* size of the payload the durable object sends size
Then I take Δt = worker_t - do_t to measure the latency for the worker to call the durable object fetch. I plot Δt/size to get the attached plot. The equation of the plotted linear regression is y = 0.16x + 295 so rate in increase in latency is 0.16 ms/KB (or 50Mbs) is this expected?. Also my interpretation of the 290 is the fixed time in ms for my DO to boot up. Is there a way to make this faster? A 290ms startup seems slow.
My main thoughts:
* Am I just doing something dumb to make this slow?
* How can I improve this scaling (the 0.16ms/KB)? Could it be caused by crossing a WASM <-> JavaScript boundary? If so, could I improve performance by rewriting this all in JavaScript.
* How can I improve the startup time?
* What are some things I should look for? I noticed I maybe be doing an extra allocation of the data, could things like that be significant.
* is there a better way to directly measure the Durable Object startup time than what I've done here?
I also attached some code snippets where I call the durable object from the worker, and the the fetch method:0 Replies
