Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm working on an iOS app that makes extensive use of databases, where users will be able to sync their data to a server. However, I'm terrified of the event that if too many users start using the app, the servers will no longer be able to handle it. I'm not a server guy at all and am not too familiar with how that works, but my question is, why do servers get overloaded and how can that be prevented? Does it have to do with who my server host is? Or is it about the efficiency of my code? If my host is a reliable server, such as Amazon AWS, am I still at risk for server problems? Bottom line is, does it have to do with the way I implement my code, or does it have to do with who my host is?

share|improve this question

closed as not a real question by Ward, Jacob, Zoredache, mdpc, Khaled Apr 13 '12 at 19:09

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
This is pretty impossible to answer in its current form but the simplest answer is "all of the above". Your code, especially with respect to database interaction will absolutely impact performance. As for the server, its not so much about the quality of the host as the type of server(s) you choose and how you spec them out. –  WerkkreW Apr 13 '12 at 16:20
add comment

3 Answers

This is a very vague question. They go down because...well, you overload them and they don't have the capacity to handle what you're throwing at them.

Think about it this way. If you have a fire, do you put it out with a garden hose, a squirt gun, or a tanker truck? Any of them can put out small fires. Big fires need more capacity.

How do you prevent it? You test. You plan for the projected load.

If you're talking about databases, you talk to a database person if your load is projected to outpace what you can handle. You need to plan out how to split tables up so you can distribute it over multiple servers, you plan for sharding, you can set up read-only servers to help with reads, master/slave setups...or you look at the underlying technology and see if a "NoSQL" server alternative can handle your needs better. And you look at where the data requests come from, to see if you can distribute your servers to be more geographically conducive for your user's requests.

There's no set answer to this because it entirely depends on what your application does, the kind of data it handles, and what you're pulling from the database.

EDIT - you asked specifically about Amazon, if there's a danger there. Amazon is like Lego. You can use their tools to build robust implementations, sure...and you'll pay extra for it. Or you can run it all off one instance and tie it to their proprietary database system. You can get your application to "work" and it still may not be fully robust. Plus Amazon isn't magic. Instances degrade, die without warning, etc...so to answer that part of your question, yes, your data is still in danger when using Amazon unless you architect around possible failures. You can set up multiple database servers spanning multiple regions as failovers, and it gets quite complicated. That's why there are people paid up to and past six figures to just work with databases. They architect around these problems for a living, and Amazon is not powered on unicorns...they do have failures.

share|improve this answer
    
Wow I didn't think it would be such an involved process. It sounds like a lot of planning is in order. I didn't think I such optimization steps would be required. Are there any companies that provide solutions to these problems without any expertise from my end? I'm not at all familiar with spacing out my databases and all that stuff, and that sounds like it might take a while to learn. Are there any companies that take care of a lot of these issues? –  maq Apr 13 '12 at 19:08
    
DBA consultants would do work like that. You could try looking for people that freelance with database administration so you can work with them on your application's particular needs. You might have some luck in the chat area for the database exchange site, or if you can search profiles in the careers site to find someone that has working knowledge of your database of choice. –  Bart Silverstrim Apr 13 '12 at 20:49
add comment

That's pretty general. It can be:

  • Race conditions due to conflicting concurrent operations (this may be caused by poor server software design)
  • Load causing the server to be unable to respond within the timeout
  • More open TCP connections than the server can handle
  • Network bandwidth saturation
  • Large numbers of threads or processes or memory allocations causing the server to run out of memory

There are several other reasons a server might fail due to load, but these cover a lot of the cases. They also cover the performance of your server, its network link, its reliability in general, and the server software you are running.

share|improve this answer
add comment
why do servers get overloaded and how can that be prevented? 

Because there're not enough resources to supply the demand. Having a single server on the backend can get overloaded by HTTP requests, for example, and in eccense, cause a denial in service.

You prevent this by fronting your services with tools like Apache and use a load balancer to distribute requests to free servers or servers with less load. The same can be done for the database, scaling horizontally or vertically (sharding)

Does it have to do with who my server host is? Or is it about the efficiency of my code? 

More with your server hosts, but code can cause it too.

If my host is a reliable server, such as Amazon AWS, am I still at risk for server problems? 

Depends, who is responsible for setting up your servlet container and how it's configured to supply requests. However, I'm not familiar with AWS and therfore can't give a adequate answer here.

Bottom line is, does it have to do with the way I implement my code, or does it have to do with who my host is?

DOS is usually due to lack of resources on the hosts side. However, if code is poorly written and designed, it will cause it as well.

For example, if you code too much controller/business logic in PSQL, you could overload the database and prevent queries from returning in a timely manner and thus result in DOS.

You could also write code which uses excessive connections on the database and have an issue where connections are no longer supplied causing DOS.

These two examples aren't necessarily an issue as a result of lack of resources, but more so an issue with not making effective use of the tools being used. Both sides are important and there are many ways to encounter DOS.

However, a good initially designed model can take you a long way. If you're unsure how to design your code, I would start by checking out MVC and SOA. Good Luck!

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.