Durable object best practice
1. yes
2. should in theory be more efficient yes since the connection is established already, but it's a different topic if your app will notice this optimization
3. I believe, yes, it's charged as far as I know. Not sure if hibernation can kick in and disconnect the target. Will double check.
4. Simplicity wise, not using the RpcTarget is better if it's just doing 2 calls. But, it can be more optimized if you will be doing lots of calls and want to avoid making an RPC each time. I didn't measure the difference nowadays but I suggest measuring it and seeing if it matters to your app.
2 Replies
Thanks 🙏 . Follow-up question: does a rpc session count towards the worker limit of 6 simultaneous outgoing connections?
If I remember correctly Durable Objects calls do not count in that. Been a while since I tested it.