4 ms·
A serious problem with this approach is scaling. When your code is in Ruby/JS/whatever on separate servers, and your traffic increases, you can easily scale up
by BurningFrog 12y ago
A serious problem with this approach is scaling.
When your code is in Ruby/JS/whatever on separate servers, and your traffic increases, you can easily scale up by adding more stateless servers.
Going from 1 to 2 DB servers is much harder, and can easily mean a major rewrite, during which your site may not really work.
- falcolas 12y agoAbsolutely this. Not to mention the need to prematurely scale up DBs due to the added load. Expensive and hard.
- radicalbyte 12y agoThe other side of the coin is that you probably won't need to scale. The performance differences can be staggering: I've replaced Java-based procedures which took more than an hour to execute with Stored Procedures which completed within milliseconds. That's an extreme example - the original code was simply incompetent - but I regularly see significant (100x) performance increase in core functions through the switch. Still, nowadays I prefer to have as much logic as possible in code because it's much easier to test and is more flexible than SPs; and it's always possible to move logic to SPs later..
- hobs 12y agoI see databases in general get a lot of flack from developers for this reason, when on the other side of the fence I see a lot of really smart people misunderstanding the tool (as your example alludes to.) I have often come to a stored procedure and not returned 100x, but more like 50,000x by simply changing a few lines of code. tl;dr anyone can write slow code in any language.
- radicalbyte 12y ago> I have often come to a stored procedure and not returned > 100x, but more like 50,000x by simply changing a few > lines of code. Oh, those beautiful nested cursors :)
- jalfresi 12y ago"Scaling is a nice problem to have" Don't write code to handle 1 million users if you've only got 100. Usually just getting something up and running is enough of a problem for most.
- y0ghur7_xxx 12y ago> A serious problem with this approach is scaling. Stack overflow runs off one SqlServer. Do you think your app is going beyond that? If yes, maybe this approach will not work for you. If no, you are in the 99,99999% of all other sites/apps that are not as big as SO, FB or google and you can use this simple way to make your site or app.
- superuser2 12y agoStackOverflow's database doesn't need to work that hard because the vast majority of traffic is read requests for public, essentially static webpages that get re-rendered and updated a handful of times in their lifecycle. I'd guess 90% or more could be served by a reverse proxy without ever touching SQL Server or even the app tier. It would be easy to exceed its DB load with an application that serves unique content to each user, is write-heavy, etc.
- y0ghur7_xxx 12y ago> It would be easy to exceed its DB load with an application that serves unique content to each user, is write-heavy, etc. Just curious: did YOU ever reach that point? I mean where a well optimized db engine reached it's limit? Can I ask you on what website?
- straws 12y agoI think the original comment was talking about the need to scale out application servers to take on additional load. Each application sever still communicates with (usually) the one database. Normally people talk about that as a way to increase the throughput of requests that your site can respond to, but it has another benefit: more time spent performing data validation, string munging, date checking, etc adds up to less time spent in the database on the same thing. Stack Overflow may run off of one relational database, but it solves the scaling problem through liberal application-level caching and reverse-proxy caching, all using about a dozen servers that connect to the one database.
- CSDude 12y agoIf you need a state, where you want those functions, checks, triggers etc, using a stateless db server and providing state with business logic is still the same thing.