If you are worried about performance because it nags at you and not because you have a specific known performance pain, I would suggest selecting a higher-performance platform and framework so that you can defer scale concerns until much later. With a high-performance framework, you can build your application with the peace-of-mind that performance won't be a problem unless your product has decent market traction.
A common problem I've observed several times with low-performance frameworks is that you can run into performance pain before you've adequately vetted your project's ability to convert customers. By comparison, a high-performance framework allows you to be experimental and relatively reckless with your application logic. Your application code can be closer to brute-force with a high-performance platform, meaning you can optimize the application code later when the time comes, rather than bringing out the big guns of scalability.
I'd argue in favor of javascript based platforms/frameworks. Angular.js is a very powerful MVC (front-end) framework that's rapidly gaining popularity. If you combine that with a Node.js server written with something like express, you'll be cooking with gas in no time.
What are you suggesting is a higher performance platform? You may get 2-3 times faster with some other framework but you aren't going to see an order of magnitude increase and you are probably going to be sacrificing ease of development.
Rails isn't the answer to every programming problem, but I don't think that Rails has any more of a scalability issue than any other framework.
> What steps can I take while I write my web app from scratch right now, to ensure that it scales beautifully when it is launched?
That question is far to generic to have a useful answer. If you want to know how to design for scalability, you need to be more specific about what needs to scale and how than just "a Ruby on Rails web app".
There are a number of different things that can scale in an application, and what you need to make one of them scale well may be counterproductive to scaling another one.
OTOH, you are probably worrying about scalability at exactly the wrong time. You either should have a clear problem to address (which you haven't yet reached), or if you know what your scalability concern is before you've started writing your app (much less encountered an actual pragmatic problem), you should be asking that question before you choose the implementation language and framework (since particular choices there may be part of the solution.)
There are a few rules I follow at the beginning of building an app.
- avoid n + 1 queries
- shorten response time as much as possible without caching (focus on good code, avoid logic etc..., least db queries as possible)
- anything that takes longer than 100ms to process I use async processing to handle it.
The main thing you need to do in order to prevent scaling issues are making sure you aren't making an absurd amount of queries per page request. I once worked on a project that was taking close to 10 seconds at scale. Turns out it was making close to 1000 DB queries per request because they were doing iterative logic and making 3-4 db calls per iteration (which was also being done in the view...) I moved it all into the controller and it was sub 1 second, and had about 80 queries left over. This is actually very common to see in Rails apps, even with some of the more prestigious consultancies out there.
If you avoid doing things that absolutely won't scale you will be fine. Rails has no issues scaling, for 99.9% of the use cases. Regardless of the framework you use you will still have plenty of scaling issues if you have Twitter/Facebook level of success. But again that is a great problem to have.
12 comments
[ 2.7 ms ] story [ 34.9 ms ] thread(in Spanish, "excelente" means "admirable")
If you're bringing in enough customers to cause you scaling problems, then that's a good position to be in.
A common problem I've observed several times with low-performance frameworks is that you can run into performance pain before you've adequately vetted your project's ability to convert customers. By comparison, a high-performance framework allows you to be experimental and relatively reckless with your application logic. Your application code can be closer to brute-force with a high-performance platform, meaning you can optimize the application code later when the time comes, rather than bringing out the big guns of scalability.
Rails isn't the answer to every programming problem, but I don't think that Rails has any more of a scalability issue than any other framework.
That question is far to generic to have a useful answer. If you want to know how to design for scalability, you need to be more specific about what needs to scale and how than just "a Ruby on Rails web app".
There are a number of different things that can scale in an application, and what you need to make one of them scale well may be counterproductive to scaling another one.
OTOH, you are probably worrying about scalability at exactly the wrong time. You either should have a clear problem to address (which you haven't yet reached), or if you know what your scalability concern is before you've started writing your app (much less encountered an actual pragmatic problem), you should be asking that question before you choose the implementation language and framework (since particular choices there may be part of the solution.)
- avoid n + 1 queries - shorten response time as much as possible without caching (focus on good code, avoid logic etc..., least db queries as possible)
- anything that takes longer than 100ms to process I use async processing to handle it.
https://www.hnsearch.com/search#request/all&q=web+framework+...
Performance really is relative. As they say: "If you always optimize for the future, you will never get there"
Many high end sites are run on rails. Load balancing/clustering will handle most traffic problems you might run in to.
If you avoid doing things that absolutely won't scale you will be fine. Rails has no issues scaling, for 99.9% of the use cases. Regardless of the framework you use you will still have plenty of scaling issues if you have Twitter/Facebook level of success. But again that is a great problem to have.