Inter request communication in Rails app

18 views
Skip to first unread message

siva subrahmanyam

unread,
Aug 5, 2017, 10:27:18 AM8/5/17
to Ruby on Rails: Talk
Hi,

Currently we are building an booking application using ROR with Postgres as backend and running over Puma. We have a requirement where user can purchase a slot to display their ads. Currently we are relaying on DB, if one user doing booking a slot then we are restricting other user to start booking for the same slot to avoid concurrency issues. Initially I thought to use redis but prior to that I want to inquiry that is there any concurrency framework where I can communicate between requests such that I can avoid DB dependency? 

Hassan Schroeder

unread,
Aug 5, 2017, 10:58:06 AM8/5/17
to rubyonrails-talk
Can you restate this? I don't understand the problem you're trying
to solve.

I certainly don't understand "avoiding dependency" on something
you already have (and need) by adding yet another dependency.

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

siva subrahmanyam

unread,
Aug 5, 2017, 1:23:11 PM8/5/17
to Ruby on Rails: Talk
Hi,

Sorry for the confusion. Currently, I solved (just avoided concurrency) issue by adding a status column to slot model. So when a user trying to purchase that slot I update status column to hold so that other user don't able to book same slot at the same time.

Now I want solve the same problem without adding DB column. How can I do that? 

Hope it clarifies. 

Hassan Schroeder

unread,
Aug 5, 2017, 1:51:56 PM8/5/17
to rubyonrails-talk
On Sat, Aug 5, 2017 at 10:23 AM, siva subrahmanyam
<subbu98...@gmail.com> wrote:

> Sorry for the confusion. Currently, I solved (just avoided concurrency)
> issue by adding a status column to slot model. So when a user trying to
> purchase that slot I update status column to hold so that other user don't
> able to book same slot at the same time.

Seems fine. Though didn't you need a field before to hold the
booked/not-booked status of the slot? which could be "pending"
as well?

> Now I want solve the same problem without adding DB column.

Why? If the "status" is an attribute of the model, why would you
*not* keep it in the DB?

It has to be persisted somewhere, and sure, you *could* use a
key-value store like Redis but what is the point? Seems like an
unnecessary complexity.

siva subrahmanyam

unread,
Aug 6, 2017, 4:23:20 AM8/6/17
to Ruby on Rails: Talk
Hi

Actually there is no status column exists in slot model. I have added column for the sake of this functionality. Now, I want to know whether we can achieve same functionality without using any persistent storage? 

Hassan Schroeder

unread,
Aug 6, 2017, 10:14:11 AM8/6/17
to rubyonrails-talk
On Sun, Aug 6, 2017 at 1:23 AM, siva subrahmanyam
<subbu98...@gmail.com> wrote:

> Actually there is no status column exists in slot model. I have added column
> for the sake of this functionality. Now, I want to know whether we can
> achieve same functionality without using any persistent storage?

No.
Reply all
Reply to author
Forward
0 new messages