4 ms·
What do I need to do to prepare my Android app for heavy usage?
Traffic handling? Load balancing? Fault tolerance? Cloud computing? Map reduce? Database optimization?
I'm writing an Uber-for-X type of platform.
I'm overwhelmed with all of this stuff and I don't know what to start with or how to start it ...
Thanks
- ascendantlogic 11y agoSomeone couldn't possibly answer this question without you giving insight into what it is your app does, what kind of traffic you're seeing now (if at all) or even what kind of traffic you reasonably expect to see.
- oingo 11y agoSorry. It's an Uber-for-X platform.
- ascendantlogic 11y agoAlright, what is the current architecture? Is the app just a dumb client and the intelligence lives on the server? Or is it flipped where the intelligence is all in the app and the server is just a central dumping ground for data? How In the course of regular usage, how many times would your app talk to your server? What would be the average size of those data transmissions? What would be the size of the edge cases? I'm not being pedantic for pedantry's sake. You need to have answers to all of these questions before you start thinking about capacity planning and high availability.
- oingo 11y agoI'm trying to draw up a schematic on paper, so this is it... 1) The app will essentially be the front-end. The user will only be using the app to make payments, view a map (with cars on the road), track their car, request / cancel a car, and provide feedback. So the heaviest usage would be from the server to the user and not the other way around. I'm not sure how much Google Maps uses up per minute and how much data is needed to push a car's new position to the phone. That would seem to me to be intensive though, especially over thousands of people. Edge cases would be 0 and 25 cars live on a map. Also, I currently have one droplet with DO. Am I supposed to have at least 3? (website, app, DB )
- ascendantlogic 11y agoBut in the spirit of trying to be helpful, I will echo the sentiments I've seen elsewhere in this thread and say your best bet will be a reasonably sized box running HAProxy fronting at least 2 boxes running nginx + your API code. Since it is highly likely you have a DB you could also run an "internal" HAproxy box fronting multiple postgres servers that are doing bidirectional data sync but that complexity ramps up QUICKLY.
- oingo 11y agoI'll get back to your last one after giving it more thought. Here's a silly question about load balancers. What would happen if my requests weren't being "load balanced"?
- DigitalSea 11y agoThe reality is you can't. Dealing with more traffic than you expected is a good problem to have. You can lay down the ground work by using something like AWS (Amazon Web Services) and using auto scaling to increase resources when load increases. At the same time, premature optimisation can be a costly mistake. If you prematurely assume your app is going to be more popular than it is, you could end up with a massive hosting bill because you spun up 200 large Amazon instances and only get 100 users. My advice would be to read this link: https://www.airpair.com/aws/posts/building-a-scalable-web-app-on-amazon-web-services-p1 https://www.airpair.com/aws/posts/building-a-scalable-web-ap... - it details building a scalable web application and I know of one startup I worked with who found it useful.
- oingo 11y agoWow .That link looks amazing, thank you!
- o_rodriguez 11y agoAs others have mentioned, YAGNI[0]. You have to avoid the tempting sirens call and wait until you actually have scaling problems, before anyone can tell you how to solve them. Make sure you follow "best practices" in whatever parts of the app you're building. Also try to have some good instrumentation in place, like New Relic for server usage/app performance and Sentry/Bugsnag/etc for catching exceptions if/when those happen. If it's mostly a client-side app that runs on someone's phone, then there really is no central scaling bottleneck. If you're worried about scaling the backing API, I'd start with one of Amazon's Elastic Load Balancers and put two micro EC2 servers behind it. If you get a ton of traffic, you can easily take one server out to increase its size without bringing the app down, or you can just add more micro/small servers and scale horizontally. [0]: http://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it http://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it
- oingo 11y agoThanks a lot. So, I'm guessing I should opt for AWS right off the bat ? (vs, say a normal VPS like DO?)
- ascendantlogic 11y agoAWS will be significantly more expensive than DO. Unless you need enterprise-grade scalability at your fingertips and have the cash on hand to ramp to that, you may want to start with a handful of Digital Ocean or Linode boxes and see what the traffic looks like.