Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Building data-driven APIs at the edge

Building data-driven APIs at the edge

As presented at Serverless in the Park on 05 May 2022

Rob Sutter

May 09, 2022
Tweet

More Decks by Rob Sutter

Other Decks in Programming

Transcript

  1. What you will learn • What are APIs at the

    edge? • How are edge functions di ff erent? • When should you use them? • How to choose a data store? • A note about authentication. Rob Sutter (@rts_rob)
  2. Who am I? • Head of DA at Fauna •

    Former AWS Serverless DA • Previous SaaS startup founder • Global active-active architecture • Mobile and web users Rob Sutter (@rts_rob)
  3. Classic serverless functions Example - AWS Lambda • Designed for

    single-region workloads • Isolated as Firecracker virtual machines • Long running - currently up to 15 minutes (wall time) • Big environments: • 10,240 MB of memory • Up to six vCPUs • Up to 10GB code with container image packaging format Rob Sutter (@rts_rob)
  4. Edge functions Example - Cloud fl are Workers • Originally

    designed for inbound HTTP requests at the edge • V8 isolates form the security boundary • Short-lived - up to 50ms of CPU time for Bundled Usage Model • Small environments: • Up to 128MB of memory • Shared processes in a single VM • 1MB code limit Rob Sutter (@rts_rob)
  5. Other changes at the edge • API Gateway is typically

    built in • Typically only JavaScript • Also WASM, so you can get Rust - kinda • Fewer related services
  6. Single-region data stores Advantages • Simpler to provision • Simpler

    to operate • Colocated with single-region assets Disadvantages • Latency for distant workloads Rob Sutter (@rts_rob)
  7. Single-region data stores Rob Sutter (@rts_rob) Region Location Distance (km)

    Speed of Light (ms) Observed latency (ms) 1 Des Moines, IA 0 0 0 2 Washington, DC 1600 5.337 16 3 New York, NY 1900 6.338 14 4 Charleston, SC 1920 6.404 21 5 Dallas, TX 1200 4.003 15 6 Denver, CO 1100 3.669 9 7 Los Angeles, CA 2800 9.340 16 8 San Francisco, CA 2900 9.673 23 9 Seattle, WA 2800 9.340 24 Simple Mean 1802 6.011 15.333
  8. Single-region data stores • AWS Aurora • MongoDB • PlanetScale

    • PostgreSQL • Xata Rob Sutter (@rts_rob)
  9. Multi-region data stores Advantages • Balanced latency • Transactions available

    • Various consistency models Disadvantages • Replication cost • Replication complexity • Maintaining consistency • Transactions (again) Rob Sutter (@rts_rob)
  10. Multi-region data stores • DynamoDB Global Tables • Fauna •

    Cloud fl are Workers Durable Objects Rob Sutter (@rts_rob)
  11. Edge data stores Advantages • Lowest latency • Single programming

    model • Integrated security model Disadvantages • Eventual consistency • Lack of transactions • Data visualization tooling Rob Sutter (@rts_rob)
  12. Review • What are APIs at the edge? • How

    are edge functions di ff erent? • When should you use them? • How to choose a data store? • A note about authentication. Rob Sutter (@rts_rob)