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

Connecting Ruby and Elixir microservices

Connecting Ruby and Elixir microservices

A talk I gave at the global gRPC Community meetup where I showcase how Platogo uses gRPC to handle thousands of requests per second using gRPC across microservices.

Daniils Petrovs

October 29, 2023
Tweet

More Decks by Daniils Petrovs

Other Decks in Programming

Transcript

  1. Connecting Ruby and Elixir microservices in a high-load gaming platform

    Daniils Petrovs - Backend Developer @ Platogo Interactive Entertainment GmbH. How we handle thousands of concurrent players on web and mobile gRPC inside!
  2. whoami? - Backend Developer primarily - Experience in micro services,

    Erlang/ Elixir/Ruby - Also do development in Go and Clojure - Occasionally contribute to open source on Github
  3. Who are we? - Social gaming company based in Vienna,

    Austria 🇦🇹 - Developing a social multiplayer platform for 10+ years (with < 25 people) - Backend, front end and design teams - Multiple micro services in Elixir and Go, with single Ruby monolith
  4. Our Platform Migrated to micro services w/ Service Mesh •

    One Ruby monolith • A few Elixir micro services • A few Go micro services • K8s on AWS EKS with Trae f ik and Linkerd • Multiple CDNs and databases • Ka f ka and RabbitMQ
  5. Moving Wallet out • Main app shouldn’t be responsible for

    balances, transactions and game sessions • Hitting limitations of Ruby • Solid inter-micro-service communication options became available • Linkerd available as lightweight service mesh with load balancing and tracing support
  6. Setting up the repositories • Protobuf de f initions in

    the Wallet server repo in a shared umbrella app • “Client” repositories relatively f ind the de f initions to generate stubs
  7. On Ruby side • Ruby gRPC support is of f

    icially supported • Easily generated client stubs (Ruby classes) from Protobuf de f initions Things were looking good! $ rails generate_grpc
  8. On Elixir side • Original Elixir gRPC fork was abandoned

    - until 2022! • Now nearly feature complete and actively developed • Mix tasks were released by OffgridElectric wrapping protoc • Still slower than e.g. Go implementation, but fast enough for us Not as great initially! $ mix compile.proto Generated protobuf app Generated escript protoc-gen-elixir with MIX_ENV=prod compile.clean gsm.pb.ex compile.clean wallet.pb.ex compile.proto apps/shared/gsm.proto apps/shared/wallet.proto
  9. Game Launcher Tool written in Elixir, uses gRPC stub under

    the hood to perform game launch f low.
  10. Game Launcher • Only for development without client builds •

    Stub client generated from the same de f initions • Uses gRPC channel wrapped in a GenServer • Took ~3 days to build for f irst partner Using gRPC client
  11. Results? • All active users on both apps migrated to

    Wallet service in 2022 • No gRPC related bottlenecks yet
  12. • Explore using gRPC server on PAS monolith (to let

    other services request stuff from it directly) • Maybe explore using gRPC on end user client side? • Develop more development and debugging tools (e.g. Go-based CLI for sending gRPC requests to services)
  13. Links • @danirukun • Github • https://danpetrov.xyz - personal website

    & blog • www.platogo.com - company website (and yes, we are hiring!) • https://github.com/elixir-grpc/grpc • https://github.com/OffgridElectric/protobuf_compiler