Building Multiplayer Applications with Cloudflare Workers & Durable Objects

Durable Objects, part of the Cloudflare Workers platform, are the solution for strongly consistent storage and coordination on the edge. In this talk, you will learn about Durable Objects, why they are suited for collaborative use-cases, and how to build multiplayer applications with them!

Video thumbnail
Recording is available to Multipass and Full ticket holders only
Please login if you have one.
Spanish audio is available in the player settings
Rate this content
Bookmark
Video Summary and Transcription
Durable Objects are a key feature of Cloudflare Workers, designed to simplify the development of collaborative applications like document editors, game servers, and chat rooms. They provide a single point of coordination between multiple clients, eliminating the need for complex multi-region deployments. This talk highlights how Durable Objects handle state and coordination, allowing for scalable solutions. The use of WebSockets facilitates real-time interactions, making them suitable for applications like a multiplayer version of Conway's Game of Life. Durable Objects pricing is based on the duration of active requests, making it a cost-effective option. The Cloudflare Durable Objects platform ensures scalability by hosting objects in multiple data centers worldwide, allowing them to handle high traffic efficiently. However, accessing a Durable Object from distant locations may introduce latency. Each object instance runs a single thread of JavaScript, which may not be ideal for high concurrency tasks. The talk also covers how Cloudflare Durable Objects pricing works, emphasizing their cost-effectiveness for applications requiring global coordination.

FAQ

Durable Objects in Cloudflare are a storage solution that allows state to be stored at the edge. They are designed for building scalable collaborative applications like document editors, game servers, and chat rooms. Durable Objects provide unique instances globally for handling state and coordination across multiple client requests.

Durable Objects are used with Cloudflare Workers to handle state and coordination in serverless environments. Workers can create and interact with instances of Durable Objects via an API, allowing state to be maintained across requests. Each Durable Object instance is uniquely addressable, ensuring consistent state management.

Cloudflare's Durable Objects are designed to be infinitely scalable by leveraging a unique global distribution model. They are hosted in multiple Cloudflare data centers worldwide, allowing them to handle a large number of requests and maintain high performance and availability.

The billing for Durable Objects is based on the wall clock time during which an object handles an active request. Once the Durable Object returns a response, billing stops, making it a cost-effective solution for applications that require intermittent coordination across global users.

Durable Objects are suitable for high traffic scenarios as long as the load is distributed across many instances. Each Durable Object handles a portion of the traffic, allowing the system to scale efficiently by distributing the workload.

One limitation is that each Durable Object instance runs a single thread of JavaScript, which may not be suitable for tasks requiring intense computation or very high concurrency. Additionally, accessing a Durable Object from far geographical locations may introduce latency.

Durable Objects are ideal for collaborative applications because they allow centralized coordination of state changes across multiple clients. This is essential for apps where users interact in real-time, such as in collaborative editing or multiplayer gaming, ensuring that all users see the same state.

Video transcription and chapters available for users with access.
Matt Alonso
Matt Alonso
27 min
14 Apr, 2023

Comments

Sign in or register to post your comment.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Living on the Edge
React Advanced 2021React Advanced 2021
36 min
Living on the Edge
The Talk discusses the future of React and introduces new APIs, including streaming rendering and server components. React Suspense allows for asynchronous loading of components and data fetching. The use of serverless computing, specifically Cloudflare Workers, is explored as a way to improve performance. The Talk emphasizes the potential for simplifying the React ecosystem and the excitement about the new API.
Database Access on the Edge with Cloudflare Workers & Prisma
Node Congress 2022Node Congress 2022
31 min
Database Access on the Edge with Cloudflare Workers & Prisma
This Talk discusses database access on the edge with CloudFlare workers and the challenges of serverless platforms. It explores solutions for database access, including CloudFlare-specific solutions and using Prisma data proxy. The Prisma toolkit and demo are showcased, demonstrating how to convert an application to use a database. The process of setting up Prisma Data Platform and deploying the application to CloudFlare workers is explained. The Talk concludes with insights on database usage and the differences between serverless, CDN, and the Edge.
Automate the Browser With Workers Browser Rendering API
JSNation 2024JSNation 2024
20 min
Automate the Browser With Workers Browser Rendering API
The Talk discusses browser automation using the Worker's Browser Rendering API, which allows tasks like navigating websites, taking screenshots, and creating PDFs. Cloudflare integrated Puppeteer with their workers to automate browser tasks, and their browser rendering API combines remote browser isolation with Puppeteer. Use cases for the API include taking screenshots, generating PDFs, automating web applications, and gathering performance metrics. The Talk also covers extending sessions and performance metrics using Durable Objects. Thank you for attending!
Static first websites with Cloudflare Workers
Node Congress 2022Node Congress 2022
30 min
Static first websites with Cloudflare Workers
The Talk covers the historical landscape of web development, the rise of static site generators, the serverless revolution, edge computing, and using Cloudflare services to enhance static websites. It explores the challenges of early web development, the shift to static sites and client-side rendering, and the advantages of server-side and client-side rendering. It also discusses Cloudflare services like Cloudflare workers, KV, durable objects, and HTML rewriter for building fast and minimal hosting solutions. The Talk highlights the use of DurableObjects for analytics and integration, dynamic content on static sites, JAMstack, and the advantages of using Cloudflare Workers for automatic deployment, multiple language support, and combining static pages with JavaScript functions. It introduces the concept of edge computing and the difference between Cloudflare Pages and Workers. It also touches on error handling and the use of HTML rewriter, Cloudflare KVstore, and DurableObjects for managing state and storing dynamic data.
The Future of JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
The Future of JavaScript Runtimes
Today's Talk explores the future of JavaScript runtimes, their evolution, and impact on software development. It discusses the historical trends of JavaScript, the adoption of new tools and libraries, and the convergence of Node and Deno. The emergence of isolate clouds and their potential to replace traditional VMs and containers is also highlighted. Additionally, the talk touches on the possibilities of JavaScript in exotic use cases, its impact on machine learning, and the potential for TypeScript to become the de facto language for JavaScript development.
Building full-stack applications on the Edge
React Advanced 2022React Advanced 2022
9 min
Building full-stack applications on the Edge
This Talk explores building full stack applications on the edge and the blurring line between front end and back end development. It discusses the benefits of using the JAMstack and APIs for scalable web development. The Talk also highlights the improvements in edge technology, such as serverless functions and efficient data storage, and the deployment of functions and durable objects on the edge network. Overall, the Talk emphasizes the importance of delivering high-quality experiences with low latency through edge computing.

Workshops on related topic