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

GraphQL as an API Gateway for E-commerce at sca...

Avatar for Yogesh Desai Yogesh Desai
February 22, 2020

GraphQL as an API Gateway for E-commerce at scale with Tooling

As many companies started using GraphQL in production with different requirements, it is now important that one should know what are the best practices for production environment. Different domain has different use-cases and according to the importance of it, the implementation may vary. We at Tokopedia, #1 Indonesian e-commerce have implemented GraphQL as an API Gateway. The main part is the scale of the Tokopedia in production. Due to the very high scale, we need to tackle a lot of problems and implement various features. This talk is mainly focussing on all of such things like Tooling needed, Observability, features like SingleFlight, Cache, Circuit Breakers, Rate limiters, Error Handling, Security Features, multi-DC/multi-cloud enability. This talk is an overview discussion of all of the above things and how to implement these on a big scale for the E-commerce domain.

Avatar for Yogesh Desai

Yogesh Desai

February 22, 2020

Other Decks in Technology

Transcript

  1. Overview • What is GraphQL • Why GraphQL • About

    Tokopedia • GraphQL @ Tokopedia • GraphQL journey inside Tokopedia • Tooling and Automation
  2. What is GraphQL? • Specification/Blueprint • Query language for your

    API • A Schema and Type system to define your data • Lets client specify exactly what it needs # A sample query query user{ user { id name } } # A sample response { "data": { "id": 3816220 "name": "Tokopedia" } }
  3. Why GraphQL? • Way better than REST for round-trip network

    calls • Saves you from API versioning hell • Get exactly what you ask
  4. About Tokopedia • A technology company founded in 2009 •

    Mission: Democratize commerce through technology • Vision: Build a Super Ecosystem where anyone can start and discover anything
  5. 2009 2014 2015 2017 Raised $1.1B funding led by Alibaba

    Moved into Tokopedia Tower (52-story building) Became first portfolio company for Softbank and Sequoia in Indonesia Raised $100M funding Pioneered instant delivery with ride-hailing companies Launched iOs app Tokopedia started C2C marketplace business Operated in small SOHO 2018 Best Indonesian App by Google Play User’s Choice 2018 Secured US$ 1.1 billion funding by Softbank Vision Fund & Alibaba Our 10th anniversary! Acquired Bridestory and Parentstory Driving more than 1% of Indonesia’s economy 2019 Our 10 years journey
  6. Yogesh Desai • Senior Software Engineer @ Tokopedia • Assistant

    Professor @ PICT • Official Contributor of LibreOffice • Volunteer in SETI@Home in/yogeshbdesai/ @yogeshbdesai
  7. GraphQL @ Tokopedia • An API Gateway • Back-End for

    Frontend • Multi-cloud Web Mobile Payment Logistics Feeds Orders Accounts APPs
  8. GraphQL journey inside Tokopedia • Adopted in late 2017 •

    Apollo with Node JS for few services • Moved to GoLang for scale • First Ramadan Ekstra 2018
  9. GraphQL journey inside Tokopedia • HUGE excitement! • Way more

    traffic than expected! • GraphQL saved the Day! • Disabled Personalizations, Enabled caching, alternate responses at GraphQL • We learned a lot!
  10. GraphQL journey inside Tokopedia • GQL Errors • Caching •

    Circuit Breakers, Rate Limiters • SingleFlight • Envoy as sidecar • Logging, alerts, Dashboards • Security Features • GQL Tools: Tooling and Automation at GraphQL layer
  11. GraphQL journey inside Tokopedia • SingleFlight ◦ A duplicate function

    call suppression mechanism ◦ Module: golang.org/x/sync ◦ Reference Medium Blog by Kale Blankenship • Benefits ◦ No duplicate requests so no extra efforts at backend microservices ◦ Improve overall performance ◦ Save cost across all the back-end microservices
  12. Tooling and Automation • GQL Tools ◦ Custom made, Complete

    End to End automation suit ◦ ResolverGen ◦ ModuleGen ◦ Node to GoLang migrator ◦ Curl to GraphQL schema Gen ◦ Integration test suit • Load tests
  13. Huge Success! • Very smooth Event! • Broke all the

    previous records • All set for Future
  14. “We are lucky to live in the internet era, where

    even the underdog can challenge the status quo and somehow eventually win” William Tanuwijaya
  15. We are Hiring! At all levels in Jakarta & India

    tokopedia.com/about in/yogeshbdesai/ @yogeshbdesai