iachat/config/initializers
Tanmay Deep Sharma a32565d72b
fix: velma connection limit (#13395)
## Description 
Make the $velma Redis connection pool size configurable via
`REDIS_VELMA_SIZE` environment variable (default: 5, matching current
behavior)
The $velma pool is used exclusively by Rack::Attack for rate limiting
and was the only Redis pool with a hardcoded size

## Fixes

Under high traffic, the hardcoded $velma pool (size: 5) causes
connection contention. Every HTTP request passes through Rack::Attack
middleware, which requires a $velma Redis connection. When
`WEB_CONCURRENCY=2` and `RAILS_MAX_THREADS=10` (20 concurrent threads),
the 4:1 thread-to-connection ratio causes threads to queue for up to 1
second (the pool timeout), resulting in intermittent request latency
spikes during traffic bursts.

The $alfred pool was already configurable via REDIS_ALFRED_SIZE — this
change brings $velma to parity.


## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)


## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Low risk: changes only Redis connection pool sizing for Rack::Attack;
misconfiguration could cause rate-limiting Redis contention or extra
connections but no data/auth logic changes.
> 
> **Overview**
> Makes the `velma` Redis connection pool (used by Rack::Attack)
configurable via a new `REDIS_VELMA_SIZE` env var, replacing the
previously hardcoded pool size.
> 
> Documents `REDIS_VELMA_SIZE` in `.env.example` alongside the existing
`REDIS_ALFRED_SIZE` setting.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
dcbc946f2e1d7356dc743178ca46cdf12cb25c78. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Vishnu Narayanan <iamwishnu@gmail.com>
2026-01-29 20:53:41 +05:30
..
monkey_patches feat(ee): Add Captain features (#10665) 2025-01-14 16:15:47 -08:00
00_init.rb Chore: Fix failing sidekiq events for contact create (#966) 2020-06-16 19:39:57 +05:30
01_inject_enterprise_edition_module.rb chore: Introduce enterprise edition license (#3209) 2021-12-09 12:07:48 +05:30
01_redis.rb fix: velma connection limit (#13395) 2026-01-29 20:53:41 +05:30
actioncable.rb chore: Enable the new Rubocop rules (#7122) 2023-05-19 14:37:10 +05:30
active_record_query_trace.rb chore: Upgrade rails and ruby versions (#2400) 2021-08-03 20:11:52 +05:30
ai_agents.rb feat: legacy features to ruby llm (#12994) 2025-12-11 14:17:28 +05:30
application_controller_renderer.rb Upgrade to rails 6 💎 (#11) 2019-08-19 13:49:57 +05:30
assets.rb chore: Upgrade rails and ruby versions (#2400) 2021-08-03 20:11:52 +05:30
audited.rb feat: Audit log APIs (#6434) 2023-03-01 20:02:58 +05:30
backtrace_silencers.rb Upgrade to rails 6 💎 (#11) 2019-08-19 13:49:57 +05:30
content_security_policy.rb feat: Vite + vue 3 💚 (#10047) 2024-10-02 00:36:30 -07:00
cookies_serializer.rb Initial Commit 2019-08-14 15:18:44 +05:30
cors.rb feat: Allow CORS api access (#11546) 2025-05-22 10:13:15 +05:30
custom_error_codes.rb Chore: Fix failing sidekiq events for contact create (#966) 2020-06-16 19:39:57 +05:30
datadog.rb chore: Handle APM variables being empty (#6594) 2023-03-02 16:00:16 +05:30
devise_token_auth.rb chore: Increase the max concurrent number of devices (#6121) 2022-12-30 13:54:37 -08:00
devise.rb chore: Fix user email re-confirmation flow (#3581) 2021-12-16 19:32:49 +05:30
event_handlers.rb Refactor Conversation model (#134) 2019-10-12 23:38:41 +05:30
facebook_messenger.rb fix: Add delay to instagram/messenger echo events to prevent duplicate messages (#12032) 2025-07-24 21:11:02 +04:00
feature_policy.rb Upgrade to rails 6 💎 (#11) 2019-08-19 13:49:57 +05:30
filter_parameter_logging.rb feat: MFA (#12290) 2025-09-18 20:19:24 +05:30
geocoder.rb fix: ip-lookup database lazy loading for all environments (#8052) 2024-10-22 23:18:30 -07:00
git_sha.rb chore: fix git_sha in instance health (#8893) 2024-02-12 14:33:15 +05:30
inflections.rb Initial Commit 2019-08-14 15:18:44 +05:30
languages.rb chore: Add bulgarian (bg) language (#12189) 2025-08-13 10:23:25 -07:00
liquid_handler.rb feat: Improved password security policy (#2345) 2021-06-07 17:26:08 +05:30
lograge.rb fix: Lograge issue on non api pages (#10193) 2024-10-01 16:53:27 -07:00
mailer.rb feat: Add Amazon SES inbound email support (#12893) 2025-11-18 15:33:08 +05:30
mime_types.rb Initial Commit 2019-08-14 15:18:44 +05:30
omniauth.rb feat: SAML authentication controllers [CW-2958] (#12319) 2025-09-10 20:02:27 +05:30
permissions_policy.rb chore: Upgrade to Rails 7 (#6719) 2023-05-06 10:44:52 +05:30
rack_attack.rb feat: add lightweight /health endpoint (#13386) 2026-01-29 00:24:01 +05:30
rack_profiler.rb chore: Improvements for codespace (#11667) 2025-06-04 00:21:23 -05:00
rack_timeout.rb chore: Set rack-timeout to log at ERROR level (#10400) 2024-11-11 12:35:05 -08:00
searchkick.rb feat(ee): Setup advanced, performant message search (#12193) 2025-08-28 10:10:28 +05:30
secure_password.rb feat: Improved password security policy (#2345) 2021-06-07 17:26:08 +05:30
sentry.rb chore: Handle APM variables being empty (#6594) 2023-03-02 16:00:16 +05:30
session_store.rb chore: Use 'Lax' instead of 'None' (#1129) 2020-08-09 18:13:17 +05:30
sidekiq.rb fix: Gate Sidekiq dequeue logger behind env (#12790) 2025-11-04 16:01:47 -08:00
stripe.rb chore: Add ee helper, custom_attributes to account (#5058) 2022-07-19 00:33:06 +05:30
warden_hooks.rb 🚨Fix Rubocop lint errors 2019-10-20 14:17:26 +05:30
wrap_parameters.rb Initial Commit 2019-08-14 15:18:44 +05:30