Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to control RPC max threads? #203

Closed
0xMostafa opened this issue Aug 18, 2024 · 2 comments
Closed

How to control RPC max threads? #203

0xMostafa opened this issue Aug 18, 2024 · 2 comments

Comments

@0xMostafa
Copy link

0xMostafa commented Aug 18, 2024

Tell us about your environment

Ruby version:
2.7

Rails version:
5.2

anycable gem version:
~> 0.6.0

anycable-rails gem version:
0.6.5

grpc gem version:
~> 1.17

What did you do?

I ran rpc process

bundle exec anycable

check the number of threads:
ps -o thcount <RPC-PID>

THCNT
  45

This number is the same locally, on staging and on prod

What did you expect to happen?

Use less threads or let me control it, like with puma's RAILS_MAX_THREADS or sidekiq's concurrency

What actually happened?

I'm load testing a chat app, it works fine for small number of users
but when i increase number of concurrent users, latency increases, up to 3-4s (depending on number of concurrent users)

I've a trace of my chat code

Screenshot from 2024-08-17 08-10-10

As you see, it takes ~500ms to start executing method's code (on ruby channel class).

I'm not sure what blank sections in trace signify but I'm guessing it could be waiting to acquire GVL to start executing. But i cannot verify it, since GVL instrumentation API was added in Ruby 3.2.0 and I'm on Ruby 2.7.

I'm trying to use less threads to check if latency decreases (waits are shorter),

how can i control bundle exec anycable's thread count?

@palkan
Copy link
Member

palkan commented Aug 19, 2024

You can set the thread pool size via the rpc_pool_size configuration parameter (e.g., in your anycable.yml). See https://docs.anycable.io/ruby/configuration?id=concurrency-settings

@0xMostafa
Copy link
Author

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants