Common hosting types
Over a decade ago, it was a common practice to host server software on dedicated private servers. In the age of cloud computing, this hasn’t changed a lot because many businesses continue using cloud services as usual servers. The typical scenario is configuring an EC2 instance on Amazon each time when a project needs a new service.
So, while this is convenient for a lazy developer, such a situation finally results in running bunches of such instances for an average-sized project. Moreover, running means paying.
On the other hand, hosting providers give us bunches of components which can reduce the number of servers used in the project.
4 Options to host your application
- Option #1: Self-managed physical server hosting.
Pros: even with low-budget hardware, it is often possible to process a lot of data/requests. The hardware is yours, and you only need to have it running.
Cons: you need a DevOps in your team. And some place or office with a reliable Internet connection and electricity supply for putting your servers.
- Option #2: Managed virtual or physical server from your hosting provider.
This option includes dedicated servers, virtual hosting, EC2, and any other kinds of service where you don’t own the server but still are responsible for configuring the operating system at a target machine.
Pros: your provider guarantees Internet connection, power supply, and physical location reliability.
Cons: you still need a DevOps.
- Option #3: Serverless technology from your Cloud provider.
Besides the compute/execution environment, this option includes all kinds of databases, integration and data processing components. The main idea is that you only need to configure the component and forget the DevOps.
Pros: with proper software design, it is possible to host your software either for free or for much-reduced costs compared to other options.
Cons: you may get stuck to a service from the specific cloud provider having it hard to migrate to another environment.
- Option #4: Hybrid Cloud.
Expensive in terms of human resources but combines the best sides of all approaches above. With that option, you can host software in different ways at a time. You can move massive operations to a physical server, serve most API requests from Lambda/Cloud functions, and put EC2 in place for traffic bursts.
Pros: for a big project, this can give the most optimal bills for the infrastructure.
Cons: again, you need a DevOps. However, there is much more DevOps work compared to other approaches.
Depending on the scale of your project, you may prefer one of these approaches. Neither of them is good or bad. It all depends on your specific business goals.
Google Cloud Platform Free Tier benefits
We are not covering the topic of enterprise and too complex solutions in this article. So let’s skip options #1 and #4. Let’s also skip option #2 because it is too common and, therefore, not much impressive.
The goal is to get the most from serverless technologies and the Hybrid Cloud, and also make all happen for free. Fortunately, Google Cloud Platform provides a lot of free services for projects which fall within specified limits. You can get the latest information at the Google Cloud Platform Free Tier page: https://cloud.google.com/free/.
The Google Cloud Platform Free Tier offers:
- 12-month, $300 free trial. That is the amount of money Google gives for the 12-month trial period to developers who want to evaluate paid services;
- Always free products. From our perspective, this is the most exciting thing. It is possible to design architectures allowing particular projects to run perpetually for free. That requires a bit of Google Cloud skills and a proper mindset for a developer. However, it pays off well in a long-term perspective.
A $300 bonus is pretty cool, but you can spend it too quickly.
The desirable goal is to build an architecture that uses free-tier products making the business consume no or limited resources for the infrastructure.
Which projects can be hosted on Google Cloud forever and totally for free?
Well, it depends on your team’s programming skills. Today, even the cheapest computer is powerful enough to do an immense amount of work. You only need to apply the most efficient way to use those resources. In 90% of all cases, you can easily explain enormous infrastructure bills by simple architecture or software development bugs.
Google Cloud Platform engineers did an excellent charity job designing the Google Cloud Platform free tiers. With a skilled team having a good understanding of the platform, it is possible to host small and middle-sized projects totally for free.
Google Cloud Platform for startups
When you work in a startup, the most critical thing is time. So, let’s describe a scenario for getting most benefits out of the Google Cloud Platform, specifically for startups.
For startups before traction
At an early stage, before getting traction, it is essential to take care of costs spent on infrastructure. The amount of data and requests processed is small. At this stage, the team mostly uses their product for showing the product to beta-testers and potential investors. This stage can last quite long, and for many projects, this stage is also the final one. For a faster time-to-market and for making the initial startup team survive with tiny budgets, it is possible to:
- Not to use a DevOps until there is a good friend who does not cost a fortune;
- Build the database architecture based on a document-oriented database. And then, use the Cloud FireStore database, which provides 1GB of data storage for free.
- For scheduled tasks and data aggregation, you can use the Google Compute Engine F1-micro instance available for free. You can use a basic Linux setup. But it is much better to configure the minimum Docker layout. F1-micro instance provides 0.2 vCPUs and 0.60 GB. Such an amount of CPU resources is enough for many tasks at the initial stage of the startup lifecycle. But 600 MB memory can be a limiting factor for starting several Docker containers. Still, in case that the project stack includes Node.js or Golang, it is possible to run several containers in such a machine. Of course, this is simpler to accomplish with Golang. Using Docker for the project is quite good for architecture because later, such layout can be scaled virtually with no limits.
- Project APIs can be built using 2 million of free invocations of Google Cloud Functions. It is not useful to spend free Google Compute Engine memory resources for hosting API in a Docker container. Instead, APIs can be deployed as lambda functions while keeping Compute Engine resources for scheduled tasks. In the future, when you exceed the Google Cloud Functions free tier limit, it is easy to scale to a paid version or migrate Cloud Functions to a Docker container or Kubernetes engine playing with https://github.com/GoogleCloudPlatform/functions-framework-nodejs.
- Implement integrations using Google Cloud Pub/Sub. 10 GB of messages per month is available for free. This amount is quite enough, even for a massive project. Of course, the architecture should not make you exhaust this limit too fast. It is easy to accomplish this by designing a message format in such a way that you reduce the total message length. Such reducing, in turn, can be accomplished by using the GRPC protocol and Google Protocol Buffers instead of JSON. And also, you should take care of the message design for the integration protocol. The pub/sub approach suits best for connecting APIs, Docker containers for data processing and aggregation, and the database side.
For startups getting traction right at the moment
When first users start using the project, it is vital to provide positive product experience. Your first users shouldn’t see any crashes, outages, DDOSes, or broken pages. Very often, the project does not get an investor due to stupid bugs while having a bright business idea and quite a complex state-of-the-art product. Oppositely, you need to track various business criteria. And you need to track any incidents for a fast incident resolution.
For all of the above, you benefit from:
- Google Stackdriver, which is providing monitoring up to 50 GB of log files via convenient dashboards. Stackdriver keeps logs for 30 days. That is enough for most cases. Also, 50 GB is quite a lot to handle even highly-loaded services.
Post-traction startup growth
You can start small. But suddenly (and this should happen one day), you get at least 5 thousand of users generating data. That is the best time to show your startup to big investors shouting about project success. But with significant resources comes significant responsibility.
The development team should be ready for the project success. And now it is time to think about:
- Creating a summary of the resources used in the project. It is good to track usage over the last 3 months, trying to predict the trend of usage growth.
- Monitor logs for crashes and get rid of them. Finally, logs should not contain crashes at all, thus reducing the log storage usage. Do not track regular activity in logs - only track events which can be interesting for incident investigations.
- Optimize CPU usage. Of course, it is much simpler to change cloud settings to empower stronger resources where the system runs slow. But this finally ends up with enabling more and more resources until you resolve the CPU technical debt. Still, in many cases, even minor code optimization is enough to solve most CPU resource issues.
- Optimize database and disk usage. That is performed the same way as CPU optimization. But the parameter analyzed is the amount of disk space. Very often, it is easy to discover that there is a place where your product tries to save a massive amount of unnecessary data.
- Enable database indexes. After cleaning up the database, you can analyze query performance. Don’t try to create indexes everywhere. The index itself consumes computer resources. It is most useful to create an index to structure data in a way convenient for reading this data and with no need to update the index very often. Otherwise, the performance can get worse than with no indexes.
- Optimize scheduled tasks. Some scheduled operations within the system may be not needed for the business goals. You should write down the list of operations performed and estimate how much each operation costs in terms of resources. Then, it is possible to optimize them for CPU usage and disk storage.
- Optimize and only then pay or migrate. For each infrastructure decision, you should consider software performance optimization options. It is easy to upgrade the server. But you can spend some effort on optimizations and win more. Each time try to optimize until that is impossible.
- Migrating and optimizing what is slow - not the other parts. Most likely, for a highly-loaded system, it is not necessary to migrate and optimize all components. You should find the bottle-necks and concentrate on optimizing them or migrating when optimization gives no more benefits.
Your infrastructure goal after getting traction is to fit the project back to Free Tier limits. When it is not possible - you need to move forward either with paid Cloud or with physical servers depending on whether you prefer to rent or to own a server.
For each decision related to the infrastructure, you need to evaluate:
- How much will you pay for resources in case that you do not invest in optimizing the software?
- Are the resources more or less expensive than software development? Here also consider that you are either paying for resources forever or do the optimization only once.
- Can you do the optimization reasonably fast not to break your product?
There is no silver bullet decision - only the solutions which are right for you at the current conditions.
Your bonus: several architecture patterns for Google Cloud Platform Free Tier
Static Website hosting
- Google Cloud Storage for keeping your website files. Free Tier includes 5 GB of file storage. That is a vast amount of space for most small sites.
- Google Public DNS is what you need for the domain name. Proper domain names are never free. We would say that Google domains are a bit more expensive than other domains. So, this is where you shouldn’t (or cannot) cut the costs.
- You need to configure a load balancer for linking all together. Load Balancer is also free, unlike some other clouds.
React.js Single Page Application hosting
When you extend your project with features - you finally add something like a dashboard written in React.js. Your project now has a single-page application. Such applications are hosted the same way as static sites. In addition to the website, you have an API which uses:
- Google Cloud Functions for API endpoints implementation. 2 million API calls per month included in the Free Tier. You should not write code which consumes that quickly at an early stage of a startup. If you have written such code, migrate this code to the Compute Engine.
WordPress site hosting
How about the most popular way to build a website? 34% of all websites are Wordpress-based. It can be a personal blog, a technical blog for the project, or even a website for enterprise business.
A WordPress website consumes server resources purely determined by the number of visitors coming to this site. So, you can easily host a WordPress blog on a free virtual machine provided by the Free Tier.
To host a WordPress site on a Google Cloud Platform free tier, you need:
- Register in the Google Cloud Platform;
- Create a project in the Google Compute Engine and install WordPress.
- While deploying, you need to choose the “micro” server instance to keep within the Free Tier.
- Configure the load balancer and DNS servers.
Hosting a REST API for a mobile application
REST API is what you have probably created while making a single-page application. Mobile applications APIs are no way different from the Single Page Application (SPA) APIs.
Best options for hosting REST APIs:
- Google Cloud Functions for API endpoints implementation. Two million API calls per month included in the Free Tier.
- But you may wish to use Google Compute Engine free instance for hosting some highly-loaded part of your APIs. Still, you do not require this in most cases.
IoT integrations MVP
Marketing guys try to squeeze much hype out of the IoT. Technically, IoT integration is a message-based, event-based API capable of processing data from various sensors reliably. Not that hard. Here comes another excellent player from the Free Tier Stack:
- Cloud Pub/Sub. The Free Tier provides 10 GB of messages per month. That is a considerable amount of messages for the early stages of a startup.
The architecture for the IoT integration should be:
- A message bus implemented using Cloud Pub/Sub to connect all parts of such a system.
- IoT sensors are talking either directly to the Pub/Sub or through Cloud Functions connected to an external domain.
- Cloud Functions or Compute Engine components processing device data.
A DataScience workspace for the MVP AI team
For a data scientist, it is nice to have a Cloud Server with pre-installed libraries, free GPU, fast Internet connection, and a powerful CPU.
- Here comes Google Colab.
- It is a Jupyter Notebook based IDE, which covers most tasks for the data science basic research.
- And even more - it is an excellent place to play for free with the Google Tensor Processing Unit (TPU), which makes most neural networks learn 28 times faster.
Speech and NLP tools
For many startups, speech recognition and NLP is like a miracle which is nice to have, but hard to reach. Here Google makes all as easy as two API calls:
- The Cloud Natural Language tool converts your texts into software-understandable items, which can be processed by any custom software. That is called text tokenization, entity extraction, semantic analysis. In any case, such a solution is hard to be home-brewed, but it sometimes provides quite good opportunities for the business.
- The Cloud Speech-to-Text engine, as well as Text-to-Speech engine is highly integrated with Google VOIP and smart assistant products (Dialog Flow, Google Assistant, Google Home). You can use them to enable speech capabilities for the project.
Startup business is a hard game. The more armor you have - the easier it is to win the game. This article is your Swiss knife for the world of cheap infrastructure decisions for your startup. It is hard to share everything we can within a single article. So, please feel free to contact us for more details on each infrastructure scenario.
And a final bonus. The summary checklist for your startup:
- Are you paying a lot for the Cloud?
- How much will you be paying for the Cloud tomorrow?
- Can you fit your project into the Google Cloud Free Tier?
- Can you continue with the Free Tier at the later stages of your business?
- Is your architecture able to save money on the infrastructure?
- Are your developers performing software optimization to consume fewer resources?
- Do your developers bother how much your infrastructure costs?
Still here? Great! Then we surely have something to discuss and take your project to the next level! Talk to our expert now.