You are on page 1of 22

Hosting For App Developers

How much will it cost to host my app?


Sebastiano Pilla
This book is for sale at
http://leanpub.com/hosting-for-app-developers
This version was published on 2016-03-30

This is a Leanpub book. Leanpub empowers authors and publishers


with the Lean Publishing process. Lean Publishing is the act of
publishing an in-progress ebook using lightweight tools and many
iterations to get reader feedback, pivot until you have the right book
and build traction once you do.
2015 - 2016 Sebastiano Pilla

Contents
1.

Why this book? . . . . . . . . . . . . . . . . . . . . . . . . . . . . .


1
1.1 Where should I host my app? . . . . . . . . . . . . . . . . . .
1
1.2 Cant I just host on the cloud? But how much will it cost me? 2
1.3 I just want to host my app (and not get broke in the process) 3
1.4 Whats in it? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 Who this book is for? . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 How to get started . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.7 What kind of app is yours? . . . . . . . . . . . . . . . . . . . . 4

2. What kinds of hosting does the market offer?


2.1 Shared hosting . . . . . . . . . . . . . . . . .
2.2 VPS (Virtual Private Server) . . . . . . . . .
2.3 Dedicated Servers . . . . . . . . . . . . . . .
2.4 Colocation . . . . . . . . . . . . . . . . . . .
2.5 Cloud . . . . . . . . . . . . . . . . . . . . . . .
2.6 PaaS . . . . . . . . . . . . . . . . . . . . . . .
2.7 Managed hosting . . . . . . . . . . . . . . . .

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.

8
8
9
11
13
14
17
19

1. Why this book?


1.1 Where should I host my app?
Your app is shaping up every day, and with each build it looks better and
better. You take a step back from the code and look at the bigger picture:

feature complete? check


tests OK? check
QA is happy? check
marketing is ready? check
hosting and infrastructure is ready? uh oh

Youve been putting off this moment for months, but now is the time to
make a decision. Your app wont make you any money just by sitting on
your laptop, you need a way to put it in front of your customers, and this
means that you have to host it somewhere.
Youre not looking for a place to host a 3-pages sales brochure, but for
something that can accommodate the unique needs of your app. You
know that hosting will be a line on your expenses sheet each month, a
line that you will never get away with.
Until now, youve been thinking that a couple of hours worth of Googling
will get you enough information to make a decision. But right after the
first 15 minutes you realize that this is an uphill battle:
theres the jargon: shared, VPS, dedicated server, cloud, PaaS, IaaS,

the pricing models: unlimited, unmetered, pay-as-you-go,


the location of the datacenter
1

Why this book?

At least the features of the various offers look quite similar (1GB of
RAM is the same everywhere, isnt it?) and youre thinking that a quick
spreadsheets will help you decide Wait, whats this managed hosting
thing? So, theres such a thing as unmanaged? And how can you figure
out whats right for you?

1.2 Cant I just host on the cloud? But how much


will it cost me?
Youre thinking
forget that, Ill just use Amazon or Google like everybody else out
there
but they dont make it clear how much you will be paying for at the end
of the month. You start to play with their pricing calculators, but instead
of getting facts and answers and you find yourself with more and more
questions:
how can I know whats the best instance type for my app?
what are hourly prices for?
does the smallest AWS instance really cost 30$ per month?
More reading and you see other offers that promise to handle all of the
syadmining things for you, but a quick glance at their pricing is enough
to convince you that hiring a part-time sysadmin would be cheaper, and
he would actually care about improving your app
Now imagine how hard it will be to really dig deeper: not only you
dont have days to spare in shopping comparisons, you just dont
have enough information to begin with! How can you possibly make
a choice?

Why this book?

1.3 I just want to host my app (and not get broke


in the process)
If you now think that choosing a host for your app is long and difficult,
youre right. If youre afraid that a bad choice will ruin your chances of
success, youre again right.
But what if you could make the best choice from the beginning? What
if you could know in advance how much it will cost, month by month,
to host your app?
What if choosing the perfect host took you just a couple of hours instead
of weeks of fruitless searching?
What if you had all the tools to sift through all the information?
This is why Ive written Hosting for App Developers.

1.4 Whats in it?


This book helps you making the best choice for hosting your app. Youll
learn:

how to decide what kind of hosting is the best for your app
how to estimate hosting costs
how to compare hosting offers
how to master the hosting industry jargon

1.5 Who this book is for?


bootstrapped SaaS founders who need to manage operating expenses
developers who suddenly become responsible for a production
environment
operations manager who want to assess their current hosting
solution against the market

Why this book?

1.6 How to get started


Following this book will be easier if you can adapt the material to your
own, unique needs. If you havent got them already, spend the next 15
minutes drawing 2 diagrams
a logical diagram: what are the different components, and how do
they work together?
maybe you have a web front-end that talks to some sort of
database
try to visualize the path of a request that enters your app and
draw where the data flows
a diagram of your ideal production environment, 6 months after
launch
try to imagine how many servers you will require for each
component, and what the specs for each of those servers could
be
Use whatever tool you like, pen and paper, Visio, draw.io, it doesnt
matter: keep those 2 diagrams with yourself as you advance to the
following chapters, and refer to the diagrams to see how the process
outlined in this book applies to your app.

1.7 What kind of app is yours?


I will show you a model application, which I will use in the rest of
this book to present the most realistic possible example. My model
application is a SaaS service that provides on-the-fly image resizing for
e-commerce web sites: our customer is someone who has a small ecommerce website and needs to show her product catalog in the best
possible quality, but doesnt have the ability to dynamically adapt the
product images to the vast variety of devices (desktop, mobiles, tablet)
that their end clients use.

Why this book?

Thats where our model app comes in: with a simple DNS change, our
customer can make our app serve all of the product images, and with
another simple change to the URL structure our app will also serve
resized images, taking all the load out of the customers infrastructure.
Our model app will have those major logical components:

web server
application server
database server
file storage

The web server is the entry point of our system: for an already resized
image, it simply returns the file as stored on our file storage system, for
a new image it forwards the request to the application server and waits
for the resized version to be available in the file storage. The application
server performs the actual image resizing and stores the data in file
storage and the metadata in the database (such as how many resized
versions exist for the original image and how many images have been
resized for each customer in a given period).
Our customers use an administration interface to upload their own
images and to configure settings such as the quality of the resized
images and the allowed sizes; our application stores these settings in
the database.
Heres the simplest possible logical diagram of our model app:

Why this book?

App logical diagram

You could choose almost any technology stack to build this model app.
If I were to build such an app Id go with the stack I know better, which
for me is:
web server: nginx
application server: Java
database server: PostgreSQL

My advice: when choosing a technology stack for a project that


should earn you money, go with the technologies you know
better. Youll always have the opportunity to rewrite the code
once youre successful, and if youre not at least you wont have
wasted any time.

With those choices, heres how my ideal production environment would


look like, 6 months after launching. There are always compromises to be
made between how robust you want your infrastructure to be and how

Why this book?

much money and effort you can dedicate to it, but at the very minimum
aim for 2x redundancy at each level of the stack.

App physical diagram

2. What kinds of hosting does the


market offer?
In the first chapter weve defined our problem: we have developed a SaaS
app and we need to find a place to host it, at a cost we can afford, with
the best possible performance and stability. If youve spent at least 30
minutes searching for hosting solutions, youll have noticed that there
are different types of hosting: PaaS, shared, VPS, dedicated, colocation,
cloud.
Some of those terms have a clear definition, others (like cloud) have been
distorted and have several different meanings, depending on whom you
ask. Lets try to clear out the confusion.

2.1 Shared hosting


On a shared hosting account you get a directory where you can put your
static files (HTML, images) and an interpreter for your dynamic pages (in
98% of the cases PHP): the server where your files live is also home to
hundreds, if not thousands, of similar websites. You share with the other
accounts the Internet bandwidth to and from the datacenter, the CPU,
the memory and the disk I/O of the server.
This is the most limited and cheapest form of hosting available on the
market. The main advantage is that you dont have to perform any system
administration tasks such as configuring the OS, the network, installing
applications, and so on.
Few providers of shared hosting give you the ability of logging in to the
actual server with SSH and you get instead some kind of control panel
that translates clicks to actions on the system. Installing applications is
often a one-click process, but you can choose only from a fixed list of
8

What kinds of hosting does the market offer?

the applications made available by the hosting company. One notable


exception is WebFaction1 : you get shell access via SSH, the ability to
compile and install your own binaries and the ability of running longrunning processes.
The hosting company configures the server to allow a certain amount of
resources to each account, and that in turn means that your account
is as limited as any other. Once you start getting too much traffic
the host may force you to move to a higher package or suspend your
account altogether. Unfortunately, the definition of too much isnt
always clearly spelled out.
My advice: shared hosting is for web pages, not for apps.
Though the cost might seem attractive at first, theres no
guarantee that you will be able to deploy your code and even if
you do, the resource limitations may kick in just when your app
starts to get some real traffic.

What shared hosting is good for:


your companys blog
a status page for your app

2.2 VPS (Virtual Private Server)


When you buy a VPS you get a slice of a physical server, on which other
virtual machines co-exist. Administering a VPS is not much different
than administering a physical server:
you get root access
you can install your own software
1

https://www.webfaction.com

What kinds of hosting does the market offer?

10

You dont have to worry about the hardware details, because the hosting
company will replace a failing disk drive or network card. Thanks to
fierce competition, buying a low-end VPS from a reputable, established
company costs around $5 per month, and many of those companies also
offer hourly billing for temporary surges in traffic and quick experimentations.
Some companies offering VPS:
Digital Ocean2
Vultr3
Linode4
You can usually get more performance out of a VPS by asking for
more CPU, RAM or disk space (scaling up) and paying an increased
fee. Resizing down is a little more difficult and not always possible: for
example, to scale down at Digital Ocean you would have to purchase a
second, smaller VPS, migrate everything over and shut down the original
VPS, thus getting a new IP address and suffering the DNS propagation
delays.
For most web applications a VPS is flexible enough to accommodate
custom binaries and particular configurations; depending on the hosting
company and on the VPS plan you choose, you may never need to move
to dedicated servers and just order more CPU and memory to respond
to increased traffic.
On a VPS youre still sharing some hardware resources: the network, the
I/O bandwidth and the CPU: if your VPS demands too much of any
of those resources, the hosting company may force you to move to a
higher plan or in the extreme case kick you out altogether. From time
to time you may see the other side of this problem: your app shows a
performance degradation without an apparent cause. This is the effect
2

https://www.digitalocean.com
https://www.vultr.com
4
https://www.linode.com

What kinds of hosting does the market offer?

11

of some neighboring VPS using too much CPU or network bandwidth,


something you cannot really predict in advance or work around.
Typically scaling up involves stopping and restarting your server, not
exactly ideal if you have to do it at peak traffic. With most VPS providers
you have to choose from a fixed set of VPS configuration and you have
no way of getting more RAM without also getting more CPU cores and
disk space.
My advice: a VPS is a good solution for starting out with a closed
beta of your app and maybe also for continued production
usage. The criteria to choose a VPS provider are:
support of KVM virtualization, which allows you to run
any operating system
a true private network between multiple VPS in the same
account, to ensure the confidentiality of the data exchange between the various components of your app
some kind of out-of-band console to access the VPS if
something goes wrong

Do not spend more than $50/month on any single VPS: at this price
point, a dedicated server is a much better value for money.

2.3 Dedicated Servers


When you buy (or more correctly rent) a dedicated server you get a
physical server that behaves in many ways like a VPS, except that you
have exclusive usage of the hardware resources:
you get root access
you can install your own software

What kinds of hosting does the market offer?

12

you can sometimes modify the hardware configuration by asking


the hosting company for additional disks or RAM
The hosting company is responsible for providing power and network,
and will replace a failing component at no additional cost, but you
will usually notice that a component is failing before they do. Noisy
neighbors that consume CPU and disk I/O are no longer an issue, your
app can utilize all of the CPU and the hardware resources of the machine.
Some companies offering dedicated servers:

Hetzner5
OVH6
LeaseWeb7
SoftLayer8

The hardware configuration is usually fixed, determined when you pay


for the setup of the machine and very rarely changes. To scale up you
typically order a more powerful machine and move your stuff. The
monthly cost of renting a dedicated server is predictable, and renting
allows you to migrate up (or down) without making initial investments
and depreciation calculations.
5

https://www.hetzner.de/en
https://www.ovh.com
7
https://www.leaseweb.com
8
http://www.softlayer.com

What kinds of hosting does the market offer?

13

My advice: a dedicated server is good when you outgrow a VPS


and you need more power for a price that isnt much higher.
Look for providers that:
offer a VLAN per customer (a true private network between the servers in the same account)
offer month-to-month payments (dont lock yourself into
multi-month contracts, even if the price is attractive)
offer a virtual console for out-of-band access and installing your own OS

2.4 Colocation
You buy your own machines, then send them to a datacenter which
provides power and connectivity. This is almost like renting dedicated
servers, except that the machines are your property and fall under your
responsibility: when some hardware component breaks, you travel to the
datacenter and replace it, or you have a datacenter technician replace it
with the spare part that you had sent originally along with the servers.
The main factors for colocation pricing are:
the height that your servers will occupy in the rack, measured in
units (a 1U server will cost less than a 2U or 4U server)
the power that your servers will draw
the bandwidth
My advice: you should buy and colocate machines only when
your business is well established and can afford the capital
expense. Over a lifespan of 2-3 years colocation can be cheaper
than renting dedicated servers, even if you factor in the hardware replacements and the labor.

What kinds of hosting does the market offer?

14

2.5 Cloud
There are as many definitions of cloud as there are hosting companies
out there. I will limit the discussion to the IaaS (Infrastructure as a
Service) variant, where you rent some computing resources (CPU, RAM,
storage, network) from a hosting company: in general those computing
resources come in the form of virtual machines, similar to a VPS. Some
companies exploit this similarity to define their services as cloud servers
where in reality they simply offer VPS with hourly billing.
Lets define what we want from a cloud hosting solution:
billing by the hour (or by the minute) of the VM and the other
resources (storage, network services)
ability to obtain more resources in minutes
ability to resize up and down the existing VM
networked storage for the VM volumes
network load balancers and firewalls are available as a service
Some companies offering cloud hosting:

Amazon AWS9
Google Cloud Platform10
Microsoft Azure11
Dediserve12
ProfitBricks13
LunaCloud14
SoftLayer15

https://aws.amazon.com
https://cloud.google.com
11
http://azure.microsoft.com
12
http://www.dediserve.com
13
https://www.profitbricks.com
14
http://www.lunacloud.com
15
http://www.softlayer.com

10

What kinds of hosting does the market offer?

15

With a cloud server you get root access and you can install your own
software. Thats about the extent of the similarities between cloud
providers, because each one has a particular service model:
some providers offer a predefined set of virtual machine configurations and you cannot add memory without also having to buy more
CPU capacity; other providers let you mix and match resources, so
you may have a virtual machine with 8 CPU cores but only 512MB
of RAM
some providers dont install the stock version of a operating system, but a special version that they have customized to better
work in their own environment (Amazon calls this an AMI - Amazon
Machine Image)
your virtual machines may come with a local disk and networked
storage is offered as an option, or there may be only networked
storage and no local disk at all
the data you store on a local disk may not necessarily conserved
after your virtual machine reboots
The list of differences grows each day, and with cloud providers introducing new features at a regular (and fast!) pace is almost impossible to
say that one provider is better than another one.
The only way to compare cloud providers is to focus on your
particular use case and try to come up with realistic, if pessimistic, estimates about your traffic and your apps usage of
computing resources.
Cloud providers also give you lot of additional services, like:
object storage: store files using a web services interface
block storage: persistent networked storage that you can mount on
your virtual machines like a filesystem

What kinds of hosting does the market offer?

16

network load balancers: distribute traffic across the various instances of your app
One aspect of cloud providers of great interest to us is that pricing is
based on usage, so the more resources you use the higher your bill will be.
You may very well pay $10 the first month and $1000 the second month.
What passes as usage depends on the particular cloud provider and
technology: for example, Amazon AWS has a block storage offering (EBS)
which is billed according not only to how much space you provision,
but also to how many I/O operations occur: good luck coming up with
a realistic estimate for it, especially when AWS itself says you may see
a different number of I/O requests on your bill than is seen by your
application 16 .
Since cloud pricing is very difficult to predict because of its own nature,
it is very important that you keep a very close watch on usage and set
up billing alerts to make sure you stay on top of hosting expenses.
Cloud hosting comes with some constraints that propagate up to the
design and development techniques: 2 instances of your app on different
VMs may suddenly no longer communicate, because one of the 2 has
been stopped for a failure of the underlying hardware node or for
a network misconfiguration. You can often achieve this resiliency by
taking advantage of the various services offered by the cloud, such as
message queues, distributed object storage or databases that automatically replicate. Keeping those constraints in mind is useful regardless of
your hosting environment, because they encourage you to think about
loose coupling of architecture components and thus producing more
robust software.
You should also keep in mind that a cloud-based hosting solution has
failure modes that you cannot really anticipate, and even the cloud
providers sometimes have troubles mastering their own creations. For
example, AWS had one notable failure in October 2012 17 related to the
EBS product which propagated to several other component: the Elastic
16
17

Amazon EBS pricing


EBS October 2012 failure

What kinds of hosting does the market offer?

17

Load Balancers were affected because the configuration was stored on


EBS volumes that were hung. The takeaway from this kind of event is
that you can mitigate the impact of cloud failures by deploying your app
in multiple zones or even with multiple providers, at a significant cost in
complexity and money.
My advice: cloud hosting makes sense only if your app really
need the particular features offered: hosting a single VM on
Amazon EC2 makes very little sense, hosting an entire infrastructure to take advantage of the load balancers, the VPC, the
scalable storage and all of the other services definitely does. For
example, I wouldnt host my personal blog on a cloud solution,
but if I were developing a server monitoring SaaS it would be my
first choice, because it would make it easier for me to respond
to increased demand.

I dont have a preference for cloud providers, though AWS seems to be


the largest and well-known provider out there: if you choose to host with
AWS you will undoubtedly find qualified help almost everywhere on the
planet.

2.6 PaaS
PaaS stands for Platform as a Service: you get to run your code on an
application, rather than directly on an infrastructure. Your code has to
obey the various conventions and rules set by the application platform,
you use some specific PaaS tools to deploy your code and in general
you dont have access to the underlying computing resources. On a PaaS
you cannot install custom software, for example a specific version of
HAProxy, but for an additional fee you can choose some add-ons in a
list pre-configured by the platform. Since you dont get direct access
to the operating system, you cannot optimize the kernel settings, nor
the storage configuration of your database: the assumption is that the
provided configuration works well enough for the kind of applications
that the PaaS supports.

What kinds of hosting does the market offer?

18

Some examples of PaaS are:


Heroku18
AWS Elastic Beanstalk19
Engine Yard20
We cannot directly compare a PaaS with VPS or dedicated hosting,
since a PaaS comes with additional services included in the price. It
would be better to compare PaaS with managed hosting, since both
provide a collection of services in addition to the simple usage of the
computing and storage resources. For example, to add a SSL certificate
in a managed hosting offer you would open a ticket and instruct the
technicians on the precise actions to perform; in a PaaS you would click
on some buttons in the control panel and the PaaS automation performs
the actual actions.
The additional services and pre-configured automation make for the
relatively high prices of a PaaS solution. For the same amount of money
that you can spend on the bare minimum Heroku configuration, you
would get several times the RAM and the CPU on any reputable VPS
provider Except that it wouldnt be the same thing, since on a VPS you
would have to install, configure and administer the machine by yourself.
A very important point is that the PaaS forces some of constraints on
your development: your app cannot write to a local file and expect to
read from this file on the subsequent requests (because your app could
have been moved to another server), logging is special The PaaS value
proposition is that there are better uses for your time that administering
a server, and that is true to an extent: however, you have to ask yourself
if working around their constraints is an effective use of your time.
My advice: use a PaaS to build a prototype of your app and
dont lock yourself into the PaaS way of doing things, because
eventually you will need a finer control over the components
that a PaaS wants to manage for you.
18

https://www.heroku.com
http://aws.amazon.com/elasticbeanstalk/
20
https://www.engineyard.com/
19

What kinds of hosting does the market offer?

19

2.7 Managed hosting


Ive decided to write a section about managed hosting even if it doesnt
fit in with the other types of hosting above. You could get a managed
VPS, a managed dedicated server, or even a managed cloud hosting: in
all cases, you buy some computing resources and a management service
from the provider. This means that the provider is responsible for the
solution to work, from providing power and network to installing the
OS, the applications, managing the backups, the security updates, etc.
What actually a provider does in a managed hosting offer changes from
one provider to another. You may not be given root access, because you
could undo the various configurations the provider has put in place, and
it may not be possible to install software which is not in a list sanctioned
by the provider. You may be forced to rearchitect your deployment
scripts and where you log diagnostic output to conform to the providers
conventions. Generally you communicate with the provider by way of
tickets, in which you ask for some action to be performed: depending
on the provider, you could give just general instructions (e.g. install the
latest stable version of nginx) or be forced to spell out the most minute
details (e.g. open a ssh session to the server XYZ, type sudo yum install
nginx and press <enter>).
Its important to stress out that a managed hosting provider wont know
anything about your app and what makes it special; typically you can find
engineers who can configure, tune and troubleshoot Apache and MySQL
and thats more or less about it. If youve developed a Node application
that talks to a MongoDB database youll have a much harder time finding
a managed hosting provider capable to help you. Managed hosting is
about you adapting your app to work with the host, and not the other
way round (as it should).
My advice: if you have even a little system administration experience, just get VPS or dedicated servers. If you dont, consider
a PaaS. Even if you find a managed provider that can help you
with your app, youll waste so much time in miscommunications
and misunderstanding that it wont be worth it.

You might also like