0

I am building a Rails service that uses Server-Sent Events (SSE) to stream events to the browser. There is a controller with standard RESTful endpoints for manipulating / querying data, and then another controller (inheriting from ActionController::Live) that handles the asynchronous code. Then, in the middle I have Redis as a pubsub

Because I am pre-computing the messages I'd like to send in the RESTful controller, I do not use the database in the SSE controller (the auth does not require a database connection).

The Problem:

Because the database connection is being unnecessarily grabbed from the pool, I am limited in the number of connections, but the number of database connections I allow.

Question:

Is there a way to skip_before_filter (or similar) to avoid requiring a database connection?

Jeremy Blalock
  • 2,538
  • 17
  • 23
  • 1
    There shouldn't be a reason why a controller would create a database connection. That is a models responsibility. Can you please post your controller? – spickermann May 22 '15 at 22:16
  • No, there is no user authentication being done (in the traditional sense at least). Instead we're just using a signed token, and we don't need to check if that user exists in the database. – Jeremy Blalock May 22 '15 at 23:15

1 Answers1

0

You can disable db connections by default. I think this SO post tells you how:

Rails 3 - how do I avoid database altogether?

Community
  • 1
  • 1
devkaoru
  • 1,142
  • 9
  • 7