Inter request communication in Rails app

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Inter request communication in Rails app

siva subrahmanyam
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? 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/92c40ca2-5473-4cf9-b83a-2724bdfdefc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inter request communication in Rails app

Hassan Schroeder-2
On Sat, Aug 5, 2017 at 7:27 AM, siva subrahmanyam
<[hidden email]> wrote:

> 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?

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 ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yCGUo5%2B2qWUtajDUW2C25xdFWD2JrkfHg2Xdyj%2BMG%3DjMQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inter request communication in Rails app

siva subrahmanyam
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. 

On Saturday, 5 August 2017 20:28:06 UTC+5:30, Hassan Schroeder wrote:
On Sat, Aug 5, 2017 at 7:27 AM, siva subrahmanyam
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="fQeCnAmyCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">subbu98...@...> wrote:

> 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?

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 ------------------------ <a href="javascript:" target="_blank" gdf-obfuscated-mailto="fQeCnAmyCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">hassan.s...@...
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9ae3d37a-c2f5-46b4-9395-f27e31ead326%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inter request communication in Rails app

Hassan Schroeder-2
On Sat, Aug 5, 2017 at 10:23 AM, siva subrahmanyam
<[hidden email]> 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.

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yBU2N35xibQ%2BqTA9Wmkz__jAg%2BSBisnpe-o23hs_LmE%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inter request communication in Rails app

siva subrahmanyam
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? 

On Saturday, 5 August 2017 23:21:56 UTC+5:30, Hassan Schroeder wrote:
On Sat, Aug 5, 2017 at 10:23 AM, siva subrahmanyam
<<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Hr0c8oW7CAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">subbu98...@...> 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.

--
Hassan Schroeder ------------------------ <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Hr0c8oW7CAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">hassan.s...@...
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/14528183-4376-4b04-9bb5-defb7740dc9c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inter request communication in Rails app

Hassan Schroeder-2
On Sun, Aug 6, 2017 at 1:23 AM, siva subrahmanyam
<[hidden email]> 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.

--
Hassan Schroeder ------------------------ [hidden email]
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yADz%2BYEf2T00igR6muj%3DDeUHKUAmbGTryXHKhctyJ_6BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...