fetch
user_ids and get a stub for each string, and read some data, and collect it together, but want to try and speed that process up as much as possibleconst ran = await runDurableObjectAlarm(stub); expect(ran).toBe(true);// expects true but is falsethis.state.getWebSockets on each stub, is this 1 DO request per stub? Do these count toward the subrequest limit of the initially invoked Worker?
Will the DO billing charge for cold-starts etc ?No, you pay only the time after your DO is running.
IF, Workers consumes 10ms (and hence billing time = 10ms) for above simple Use-case, is it "FAIRLY ACCURATE" to assume that the DO will also consume 10ms (and hence billing time = 10ms) for the same Use-case.Assuming that the
10ms is actual round trip time for your operation, then yes, DOs should have similar performance as Workers. It's the same runtime so code behavior is identical.@cloudflare/next-on-pages with DO's?durable-utils@0.3.0: https://github.com/lambrospetrou/durable-utils#readmeStaticShardedDO abstraction extended with more methods one/some/all() and tryOne/trySome/tryAll(). There are a couple other utilities added for retries like tryN(...).StaticShardedDO class and let me know what you think or what's not convenient.Conclusion : Workers Compute is 12.5x times COSTLIER than DO-Compute.That's a very unusual conclusion for real world applications. Anyone can do their calculations of course, but please be careful when you compare them otherwise you will be in for not so nice surprises.
const ran = await runDurableObjectAlarm(stub); expect(ran).toBe(true); it("adds jobs and schedules an alarm", async () => {
const result = await runInDurableObject(stub, async (instance, state) => {
return await instance.addJobs([
{ url: "https://example.com" },
{ url: "https://example.org" },
]);
});
expect(result).toBe("Jobs added");
// Run the alarm (which calls processQueue & processTimeouts)
const ran = await runDurableObjectAlarm(stub);
expect(ran).toBe(true);
const status = await runInDurableObject(stub, async (instance) => {
return await instance.getStatus();
});
expect(status).toEqual([{ status: "pending", count: 2 }]);
});Durable Object alarms are not reset between test runs and do not respect isolated storage. Ensure you delete or run all alarms with runDurableObjectAlarm() scheduled in each test before finishing the test. afterEach(async () => {
// Clear any pending alarms between tests.
await runInDurableObject(stub, async (_instance, state) => {
await state.storage.deleteAlarm();
});
vi.restoreAllMocks();
});this.state.getWebSockets10ms@cloudflare/next-on-pagesdurable-utils@0.3.0StaticShardedDOStaticShardedDOone/some/all()tryOne/trySome/tryAll()tryN(...)