Marnen: here are some more details. I need to be able to handle at least 
10 API requests / second. Let met clarify what happens:

1) User makes a RESTful API request
2) I find a record in a database, return it as JSON
3) I record the request counter for the user in the database (i.e. if I 
user makes 2 API calls, I record '2').

#1 and #2 are really fast in SQL - they are SELECTs. #3 is really slow, 
because it's an UPDATE. In the real world, my database (MySQL) is NOT 
scaling. According to New Relic, #3 is taking most of the time.

Any suggestions?

Marnen Laibow-Koser wrote:
> Frank Poo wrote:
>> 
>> 
>> Hi folks:
>> 
>> I'm building something akin to Google Analytics and currently I'm doing
>> real time database updates.  However this isn't really scaling anymore,
>> so I need to stop doing synchronous DB operations.  In the short term,
>> I'm trying to reduce DB writes, so I'm thinking about a global hash (say
>> declared in environment.rb) that is accessible from my controllers and
>> models that I can write to in lieu of writing to the DB.  [...]
>> 1) Does this sound reasonable?
> 
> No!  Databases should scale as much as you need them to -- that's what 
> they are designed for.  If your DB is not scaling, there is something 
> wrong, either in your DB setup or in the way the app is using the DB. 
> Find the problem and fix it rather than ripping out the DB.
> 
> Best,
> --
> Marnen Laibow-Koser
> http://www.marnen.org
> [email protected]

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to