-
Notifications
You must be signed in to change notification settings - Fork 73
Server: Installation
Installing gruf as a server is fairly straightforward. First, add the gem to your Gemfile:
gem 'gruf'
Then in an initializer or before use:
require 'gruf'
You can configure and customize Gruf further:
Gruf.configure do |c|
c.server_binding_url = 'grpc.service.com:9003'
end
To customize parameters for the underlying GRPC::RpcServer, such as the size of the gRPC thread pool, you can pass them in via Gruf.rpc_server_options.
Gruf.configure do |c|
# The size of the underlying thread pool. No more concurrent requests can be made
# than the size of the thread pool.
c.rpc_server_options = c.rpc_server_options.merge(pool_size: 100)
end
Gruf uses the DEFAULT_POOL_SIZE
from grpc
to determine the default thread pool size - 30
. Therefore, each Gruf process can handle 30 concurrent requests.
You should tune this number to match your application performance characteristics to ensure your application is not being starved of CPU or RAM.
Additionally, you will need to ensure that your ActiveRecord database connection pool size matches or exceeds the gRPC pool size if each thread needs to be able to make database calls concurrently. Your database (MySQL or Prostgres) max user connections setting should be adjusted to ensure each database connection in the ActiveRecord connection pool can establish a valid connection.
Make sure to review UPGRADING.md if you are upgrading gruf between minor or major versions.
Next: Generating Stubs