Hosting questions for a "high" traffic rails application
Asked Answered
G

1

5

I've got a question concerning hosting for a high traffic rails application. The thing is i have 3 / 4 years experience with Ruby on Rails applications but i never had a high traffic website before. I'm really excited because this is the "next level" for me and my co-worker. The thing is we don't have experience with a rails application to handle "high traffic", first of all let me define "high traffic" in this case.

We are developing a rails application for one of the leading dutch telecom providers and the approx. visitors per day will be around 400.000 users. We are programming in ruby 1.9.2 and Rails 3.1. We are using devise for authentication handling. But we are looking for a reliable party to host this application. We are looking at Heroku but i don't have a clue what i need and how much workers, dyno's and/or dedicated database i need. We need to stream movies, and we are planning to host them on a amazon s3 bucket.

So the thing is i'm looking for advice concerning Heroku and/or other professional and reliable parties. Are there things i need to take in consideration concerning the rails application?

Thanks!

Gardant answered 12/10, 2011 at 18:53 Comment(0)
B
9

It's quite easy to roughly work it out in terms of dynos.

A dyno is single threaded so if your page takes 200ms to render you can render 5 pages per second. You need to figure out how many pages per second those 400,000 users will make. Then you know how many pages per second are being requested and what a single dyno can handle. So you'd simply increase you dyno count until you meet your user requests per second figure.

eg 1 dyno @ 200ms = 5 pages per second 2 dynos @ 200ms = 10 pages per second

etc etc. It's only a ball park figure as there are going to be other factors like DB performance etc but rest assured Heroku is suited for this type of scenario since it's just so easy so add more dynos to increase through put.

You will need to use workers for any long running event, eg sending email etc where there's a third party that may take time to respond and handling queues if your application uses them.

Once you go over 20Gb database then you need to be using a dedicated database and it sounds like from the client that the $200 per month starter DB isn't going to make them sweat in tersm of hosting costs.

Did i miss anything? If i did get back to me,

Brunner answered 12/10, 2011 at 20:12 Comment(4)
with 1 dyno do you mean a web or a worker dyno? And what does a worker dyno do? Can i see this as paperclip upload processes and rmagick / imagemagick photo manipulation?Gensler
So it's a little confusing. It used to be dynos (for web) and workers (for background jobs). On the new stack 'Cedar' you just have processes. A worker should be used for anything that can be performed in the background or is likely to take a long time. If you don't then things like resizing images in the same request as the web page would mean that dyno(or web process) is unable to process other stuff whilst it's busy. So in coming requests would be queued and ultimately timed out if they don't receive a response within 30seconds.Brunner
Thanks for your help! I've got another question concerning security. Are there things i need to think of? Do i need to make id's random and unpredictable? And what would be the best way of doing that?!Gensler
that's a very wide open question. I usually always use the default integer for IDs, you just need to make sure that since you can just type an id in the URL then the user performing the action is allowed to do it, ie if it's their account for example they can view it etc. If you follow that you should be fine.Brunner

© 2022 - 2024 — McMap. All rights reserved.