Cost optimized logging using API Gateway, SQS and Elastic Search

AWS User Group Bengaluru
AWS User Group BengaluruAWS User Group Bengaluru
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Cost Optimized Logging Using API
Gateway, SQS and ElasticSearch
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Mitesh Sharma
Tech Lead at Kiwi India Pvt Ltd
Find Me:
LinkedIn : https://www.linkedin.com/in/mitesh-sharma-76722015
Twitter : https://twitter.com/mitesh_dev
Github : https://github.com/MiteshSharma
Who Am I?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What We Do?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Joyride App
Play Social Real Time Interactive Game Shows
Players Can Win Real Cash Prizes
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Game shows are fun to play
Social interaction in real time games
Players can play in team or solo
Players win real cash
During game shows, multiple messages exchanges in real time
In last 1 minute of game show start, everyone enters app
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What Problem We Want To
Solve?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Identify customer issues during game show,
fix them and give them best experience
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How to solve customer issues?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Capture logs, understand them, identify
issues, pinpoint code where things went
wrong and fix them
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Client App
Logs on
server
Investigate
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Solution should be robust, cost effective and
scalable
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What we build?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront
Log
Service
MongoDB
EBSELB
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How to scale as traffic
increases?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Auto Scaling group helps with cost and handle huge traffic
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Auto Scaling group helps with cost and handle huge traffic
All users come in less than a minute, so auto scaling can’t help
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Auto Scaling group helps with cost and handle huge traffic
All users come in less than a minute, so auto scaling can’t help
Use time based instances
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Auto Scaling group helps with cost and handle huge traffic
All users come in less than a minute, so auto scaling can’t help
Use time based instances
Once game show ends, traffic becomes normal
Multiple game shows scheduled one after another
Effectively need to keep all instances running for whole day
Cost of running multiple instances are high
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What other components were
taking up cost?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
● Self hosted MongoDB cluster
● MongoDB needed high IOPS EBS to write these logs as
they arrive
● Used Provisioned IOPS EBS
● When there is less traffic, still paying for high provisioned
IOPS
● Needed to write queries for fetching data from MongoDB
● Build custom dashboard for logs
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What can go wrong here?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront
Log
Service
MongoDB
EBSELB
Crash
Crash
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
How we solved these problems?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront API Gateway SQS ElasticSearchFetcher
Kibana
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why we choose each service?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS API Gateway
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
● Easy to manage
● Easy to scale
● No minimum fees
● Act as Proxy
● Endpoints are public
● Easy monitoring using cloudwatch
● Perfect for our use case
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront API Gateway
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS SQS
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
● Messaging queue service
● Reliable and scalable
● No minimum fees
● Provides decoupling
● Resilience
● Push/Pull architecture
● At-least-once delivery guarantee
● Easy monitoring using cloudwatch
● Receive messages from API Gateway for later processing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront API Gateway SQS
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS ElasticSearch With Kibana
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
● Real time, distributed, search and analytics engine
● Schema free
● Developer friendly REST APIs
● Easy to deploy and manage cluster
● Secure
● Comes with build-in Kibana
● Kibana provides visualization of data in elasticsearch
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront API Gateway SQS ElasticSearch
Kibana
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fetcher Service
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
● Custom java service
● Periodically polling
● Send messages to Elasticsearch
● Dynamic polling behaviour
● Delete messages once processed
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront API Gateway SQS ElasticSearchFetcher
Kibana
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
What can go wrong here?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Route53
Cloudfront API Gateway SQS ElasticSearchFetcher
Kibana
Crash
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Learning
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
● Use managed services and focus on solving problem
● SQS can be really good in making asynchronous architecture
● Add alerts on SQS message duration
● Push messages in bulk in elasticsearch
● Keep deleting old messages from elasticsearch
● Cost is part of your efficient architecture
● Making customer happy is not easy
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thanks
1 of 42

More Related Content

What's hot(18)

It's all about the data - Tel Aviv Summit 2018It's all about the data - Tel Aviv Summit 2018
It's all about the data - Tel Aviv Summit 2018
Amazon Web Services171 views
Nader Dabit - Intro to AWS AppSync.pdfNader Dabit - Intro to AWS AppSync.pdf
Nader Dabit - Intro to AWS AppSync.pdf
Amazon Web Services316 views
Websites go Serverless - Floor28Websites go Serverless - Floor28
Websites go Serverless - Floor28
Boaz Ziniman59 views

Similar to Cost optimized logging using API Gateway, SQS and Elastic Search(20)

Microservices for StartupsMicroservices for Startups
Microservices for Startups
Amazon Web Services303 views
Containers for StartupsContainers for Startups
Containers for Startups
Amazon Web Services148 views
AI Powered Conversational InterfacesAI Powered Conversational Interfaces
AI Powered Conversational Interfaces
Amazon Web Services392 views

More from AWS User Group Bengaluru(20)

Demystifying identity on AWSDemystifying identity on AWS
Demystifying identity on AWS
AWS User Group Bengaluru439 views
AWS Secrets for Best PracticesAWS Secrets for Best Practices
AWS Secrets for Best Practices
AWS User Group Bengaluru930 views
Cloud SecurityCloud Security
Cloud Security
AWS User Group Bengaluru1.9K views
Medlife journey with AWSMedlife journey with AWS
Medlife journey with AWS
AWS User Group Bengaluru336 views
Slack's transition away from a single AWS accountSlack's transition away from a single AWS account
Slack's transition away from a single AWS account
AWS User Group Bengaluru213 views
Log analytics with ELK stackLog analytics with ELK stack
Log analytics with ELK stack
AWS User Group Bengaluru2.2K views
Serverless CultureServerless Culture
Serverless Culture
AWS User Group Bengaluru255 views
Refactoring to serverlessRefactoring to serverless
Refactoring to serverless
AWS User Group Bengaluru351 views
Amazon EC2 Spot Instances WorkshopAmazon EC2 Spot Instances Workshop
Amazon EC2 Spot Instances Workshop
AWS User Group Bengaluru475 views
AWS Secrets for Best PracticesAWS Secrets for Best Practices
AWS Secrets for Best Practices
AWS User Group Bengaluru438 views
Cloud SecurityCloud Security
Cloud Security
AWS User Group Bengaluru12.4K views
Amazon EC2 Spot InstancesAmazon EC2 Spot Instances
Amazon EC2 Spot Instances
AWS User Group Bengaluru735 views
Cost Optimization in AWSCost Optimization in AWS
Cost Optimization in AWS
AWS User Group Bengaluru1.2K views

Recently uploaded(20)

Java Platform Approach 1.0 - Picnic MeetupJava Platform Approach 1.0 - Picnic Meetup
Java Platform Approach 1.0 - Picnic Meetup
Rick Ossendrijver23 views
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
METHOD AND SYSTEM FOR PREDICTING OPTIMAL LOAD FOR WHICH THE YIELD IS MAXIMUM ...
Prity Khastgir IPR Strategic India Patent Attorney Amplify Innovation23 views
CXL at OCPCXL at OCP
CXL at OCP
CXL Forum183 views
The Research Portal of Catalonia: Growing more (information) & more (services)The Research Portal of Catalonia: Growing more (information) & more (services)
The Research Portal of Catalonia: Growing more (information) & more (services)
CSUC - Consorci de Serveis Universitaris de Catalunya51 views
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL Preview
CXL Forum118 views
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet48 views

Cost optimized logging using API Gateway, SQS and Elastic Search

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Cost Optimized Logging Using API Gateway, SQS and ElasticSearch
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Mitesh Sharma Tech Lead at Kiwi India Pvt Ltd Find Me: LinkedIn : https://www.linkedin.com/in/mitesh-sharma-76722015 Twitter : https://twitter.com/mitesh_dev Github : https://github.com/MiteshSharma Who Am I?
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What We Do?
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Joyride App Play Social Real Time Interactive Game Shows Players Can Win Real Cash Prizes
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Game shows are fun to play Social interaction in real time games Players can play in team or solo Players win real cash During game shows, multiple messages exchanges in real time In last 1 minute of game show start, everyone enters app
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What Problem We Want To Solve?
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Identify customer issues during game show, fix them and give them best experience
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How to solve customer issues?
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Capture logs, understand them, identify issues, pinpoint code where things went wrong and fix them
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Client App Logs on server Investigate
  • 11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Solution should be robust, cost effective and scalable
  • 12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What we build?
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront Log Service MongoDB EBSELB
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How to scale as traffic increases?
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Auto Scaling group helps with cost and handle huge traffic
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Auto Scaling group helps with cost and handle huge traffic All users come in less than a minute, so auto scaling can’t help
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Auto Scaling group helps with cost and handle huge traffic All users come in less than a minute, so auto scaling can’t help Use time based instances
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Auto Scaling group helps with cost and handle huge traffic All users come in less than a minute, so auto scaling can’t help Use time based instances Once game show ends, traffic becomes normal Multiple game shows scheduled one after another Effectively need to keep all instances running for whole day Cost of running multiple instances are high
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What other components were taking up cost?
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ● Self hosted MongoDB cluster ● MongoDB needed high IOPS EBS to write these logs as they arrive ● Used Provisioned IOPS EBS ● When there is less traffic, still paying for high provisioned IOPS ● Needed to write queries for fetching data from MongoDB ● Build custom dashboard for logs
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What can go wrong here?
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront Log Service MongoDB EBSELB Crash Crash
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. How we solved these problems?
  • 24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront API Gateway SQS ElasticSearchFetcher Kibana
  • 25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Why we choose each service?
  • 26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS API Gateway
  • 27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ● Easy to manage ● Easy to scale ● No minimum fees ● Act as Proxy ● Endpoints are public ● Easy monitoring using cloudwatch ● Perfect for our use case
  • 28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront API Gateway
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS SQS
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ● Messaging queue service ● Reliable and scalable ● No minimum fees ● Provides decoupling ● Resilience ● Push/Pull architecture ● At-least-once delivery guarantee ● Easy monitoring using cloudwatch ● Receive messages from API Gateway for later processing
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront API Gateway SQS
  • 32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS ElasticSearch With Kibana
  • 33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ● Real time, distributed, search and analytics engine ● Schema free ● Developer friendly REST APIs ● Easy to deploy and manage cluster ● Secure ● Comes with build-in Kibana ● Kibana provides visualization of data in elasticsearch
  • 34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront API Gateway SQS ElasticSearch Kibana
  • 35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Fetcher Service
  • 36. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ● Custom java service ● Periodically polling ● Send messages to Elasticsearch ● Dynamic polling behaviour ● Delete messages once processed
  • 37. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront API Gateway SQS ElasticSearchFetcher Kibana
  • 38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. What can go wrong here?
  • 39. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Route53 Cloudfront API Gateway SQS ElasticSearchFetcher Kibana Crash
  • 40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Learning
  • 41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ● Use managed services and focus on solving problem ● SQS can be really good in making asynchronous architecture ● Add alerts on SQS message duration ● Push messages in bulk in elasticsearch ● Keep deleting old messages from elasticsearch ● Cost is part of your efficient architecture ● Making customer happy is not easy
  • 42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thanks

Editor's Notes

  1. Explain what are the customer issues.
  2. Log service goes down, then no logs can be received for processing.
  3. Make easy to publish, maintain, monitor and secure APIs at any scale Handle all of the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls
  4. SEcure using IAM, VPC, cloudtrail and cloudwatch monitoring
  5. Polling frequency keep changing due to use case , as we receive bulk messages in a given time frame Once message is pushed to elasticsearch then it is deleted from SQS