Slide 1

Slide 1 text

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!

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

25K+ concurrent users

Slide 7

Slide 7 text

~7000 Spins per second

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Putting it all together

Slide 14

Slide 14 text

Putting it all together

Slide 15

Slide 15 text

Bonus: Supporting client apps

Slide 16

Slide 16 text

Game Launcher Tool written in Elixir, uses gRPC stub under the hood to perform game launch f low.

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Results? • All active users on both apps migrated to Wallet service in 2022 • No gRPC related bottlenecks yet

Slide 19

Slide 19 text

Future?

Slide 20

Slide 20 text

• 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)

Slide 21

Slide 21 text

Thank You & Danke schön!

Slide 22

Slide 22 text

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