Pitaya is an easy to use, fast and lightweight game server framework with clustering support and client libraries for iOS, Android, Unity and others through the C SDK. The goal of pitaya is to provide a basic development framework for distributed multiplayer games and server-side applications.
- Go >= 1.10
- etcd (used for service discovery)
- nats (optional, it's used for sending and receiving rpc, you can use grpc implementations too if you prefer)
- docker (optional: for running etcd and nats dependencies on containers)
clone the repo
git clone https://github.com/topfreegames/pitaya.git
setup pitaya dependencies
make setup
Here's how to run one of the examples:
Start etcd (this command requires docker-compose and will run an etcd container locally, you may run an etcd without docker if you prefer)
cd ./examples/testing && docker-compose up -d etcd
run the connector frontend server from cluster_grpc example
make run-cluster-grpc-example-connector
run the room backend server from the cluster_grpc example
make run-cluster-grpc-example-room
You should now have 2 pitaya servers running, a frontend connector and a backend room. You can then use pitaya-cli a REPL client for pitaya for sending some requests:
$ pitaya-cli
Pitaya REPL Client
>>> connect localhost:3250
connected!
>>> request room.room.entry
>>> sv-> {"code":0,"result":"ok"}
make test
This command will run both unit and e2e tests.
#TODO
#TODO
- TFG Co - Initial work
- nano authors for building the framework pitaya is based on.
- pomelo authors for the inspiration on the distributed design and protocol
-
Other pitaya-related projects
-
Documents
-
Demo
using grpc
===============RUNNING BENCHMARK TESTS WITH GRPC===============
--- starting testing servers
--- sleeping for 5 seconds
goos: darwin
goarch: amd64
BenchmarkCreateManyClients-30 2000 732922 ns/op
BenchmarkFrontHandlerWithSessionAndRawReturnsRaw-30 2000 712525 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtr-30 2000 704867 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrManyClientsParallel-30 2000 647892 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrParallel-30 2000 692803 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtr-30 2000 880599 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtrParallel-30 2000 630234 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtr-30 1000 1123467 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallel-30 2000 667119 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallelMultipleClients-30 2000 664865 ns/op
using nats
===============RUNNING BENCHMARK TESTS WITH NATS===============
--- starting testing servers
--- sleeping for 5 seconds
goos: darwin
goarch: amd64
BenchmarkCreateManyClients-30 2000 873214 ns/op
BenchmarkFrontHandlerWithSessionAndRawReturnsRaw-30 2000 702125 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtr-30 2000 794028 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrManyClientsParallel-30 2000 769600 ns/op
BenchmarkFrontHandlerWithSessionAndPtrReturnsPtrParallel-30 2000 702894 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtr-30 2000 984978 ns/op
BenchmarkFrontHandlerWithSessionOnlyReturnsPtrParallel-30 2000 699000 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtr-30 1000 1945727 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallel-30 2000 784496 ns/op
BenchmarkBackHandlerWithSessionOnlyReturnsPtrParallelMultipleClients-30 2000 846923 ns/op