Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Is AWS ready to provide serverless WebSockets at scale?

Is AWS ready to provide serverless WebSockets at scale?

Building WebSocket services should be easy by now, but it’s still notoriously difficult. With the launch of AWS AppSync and WebSockets for API Gateway, can we build high-scale WebSockets services using serverless technologies? What steps can we take to build a globally-resilient solution?

View the presentation: https://youtu.be/JfY_u0jeEc4

Simon Tabor

April 27, 2019
Tweet

Other Decks in Programming

Transcript

  1. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Who am I? @simon_tabor Software Engineer Simon Tabor
  2. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Covering… • Our Requirements • AWS AppSync • WebSockets for API Gateway • AWS IoT • Our Solution • The Future!
  3. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Product Requirements • Support live events • Users get new Key Moments within 30s • Support catch-up events
  4. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    System Requirements • Publish updates to users, rather than have the users poll • Retrieve previous messages and subscribe to new messages • Perform with high-traffic on a global scale
  5. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Why Serverless? Capacity Time Capacity Requirement Autoscaled Capacity
  6. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    How it’s sold AppSync aws.amazon.com/appsync/
  7. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Cons: DynamoDB • Each user performs an AppSync query on connection • 1 AppSync query = 1 DynamoDB query • Limit of 3,000 read-units per second per partition • Limit of 3,000 new users connecting per second per fixture AppSync
  8. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Cons: DynamoDB Caching AppSync CloudFront DynamoDB Accelerator ElastiCache
  9. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Cons: DynamoDB Solutions • Duplicate data N times when writing to DynamoDB • Front-end selects a random number between 1 and N • Resolves query load for now • Increased costs, higher latency, no single source-of-truth AppSync
  10. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    How it’s sold aws.amazon.com/blogs/compute/announcing-websocket-apis-in-amazon-api-gateway/ WebSockets for API Gateway
  11. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Pros: Flexible WebSockets for API Gateway • Access to send messages to each individual connection • Incredibly versatile, more control than AppSync • Fully serverless, can use Lambda for all actions
  12. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Cons: Broadcasting • Designed for sending specific messages to specific users • Not designed to broadcast a single message to millions of users • Need to invoke a Lambda for each connection and store state in DynamoDB • Need to make an API call to AWS for each connection WebSockets for API Gateway
  13. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Cons: Broadcasting WebSockets for API Gateway
  14. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    How it’s sold AWS IoT aws.amazon.com/iot-core/
  15. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Pros: Mature • Mature solution with huge number of features • Many irrelevant for us due to IoT focus • Good monitoring AWS IoT
  16. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Cons: Authentication AWS IoT docs.aws.amazon.com/iot/latest/developerguide/protocols.html
  17. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Requirements • Shared WebSocket connection for Subscribe and Query • Global scale with no race conditions • Minimal operational overhead • Generic for use by other applications? Pubby
  18. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Failovers Pubby 0 750,000 1,500,000 2,250,000 3,000,000 0 mins 2 mins 4 mins 6 mins 8 mins 10 mins 12 mins 14 mins EU Central 1 US East 1
  19. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Conclusions • Deals with a specific use-case • Service can be used by other teams at DAZN • Highly-available with seamless regional failover • Single, shared, native WebSocket connection Pubby
  20. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Conclusions • AppSync is incredibly powerful • Key Moments requirements are simple • Subscriptions are weakest part of GraphQL • Managed services have downsides • Recommended for a service with many related models AppSync
  21. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Conclusions • Opens huge opportunity to use WebSockets • Lack of broadcasting immediate deal-breaker • Great for non-broadcast services • Updates and improvements coming soon? WebSockets for API Gateway
  22. Is AWS ready to provide serverless WebSockets at scale? @simon_tabor

    Conclusions • Massive scale • Solution would need to be designed specifically for AWS IoT • Authentication doesn’t suit us AWS IoT