How to scale a webapp after Heroku - google-app-engine

Heroku's great, but expensive. How do most startups scale after hosting with Heroku starts getting too costly?
Let's say we're running rails on a linux server, typical bandwidth and storage needs.
Rackspace? I've just heard of getting into trouble if you go down this route.
Google app engine I've heard is another dangerous route.
Amazon Web Services? Just peel off Heroku's layer and save the money there?

Heroku is a value added layer of services on top of AWS EC2.
If Heroku is more expensive, you can run your own app servers on AWS using EC2 (app servers), ELB (load balancer), ElastiCache (memcached/redis), and RDS (Postgres/Mysql).
All of the Heroku services are provided on top of their applications running on AWS EC2.
Heroku allows ease of use and implements tools/services you will need to build yourself (deployment, scaling, etc). They do this at a premium over the cost of the raw AWS services. You may be able to achieve lower costs and economies of scale with larger instances.

Rackspace has a couple of options for hosting.
Rackspace Cloud: this option is very similar to Amazon but somehow is a bit more limited on the some of features they provide. However, their prices are a bit more competitive's than AWS's. They provide a Rest API as well that you can use to manage your servers programmatically (Although not compatible with AWS's API)
Rackaspace Hosting: with this option you get the whole physical server/infrastructure for you to manage. This option is very cost effective if you need a lot of CPU power (physical CPU) and you use your servers permanently (no on-demand). For example, we created an entire Cloudera/Hadoop cluster using several machines using Rackspace and migrated all of our jobs from EMR (Amazon's Elastic Map Reduce) to our physical cluster with more than 50% savings. The downside to this option is that you generally have to manage the physical servers yourself.

Related

How can I deploy an angular-spring-postgres application on gcp?

I'm new to GCP and currently, I try to deploy all my applications on their services.
For an application in a single container I use CloudRun which I already really like.
Now I want to deploy an application that uses Angular in the frontend and spring in the backend and a SQL-DB (Postgres). Every part of this is in its own separated container.
Should I use for this purpose although CloudRun or does GCP have more suitable services I should consider to use if I want to host a scalable and serverless Application? So is there such a thing as the best practice for Frontend-backend architecture applications on GCP?
I recommend you to use these services:
Cloud SQL to host the database. It's managed for you and efficient
Cloud Run for the business tier (the spring application).
Be careful, with spring the cold start can take several seconds. I wrote an article on this (the article is quite old and the perf are now better on Cloud Run, but the latency on the first request exists (and take 5 - 7s for an hello world container)). Add several CPU (4 is a good number) to speed up the cold start or use the --min-instance parameter for this (or other solution that you can find in one of my articles)
For the front end, I recommend you to host the static files on Cloud Storage.
To serve this on internet, put a Load Balancer in front of this
Create a serverless network endpoint group (NEG) for Cloud Run service
Create a Cloud Storage backend to serve the static files.
Use the domain that you want and serve it in SSL
Optionally, use CDN to cache your static files.
CloudRun runs stateless containers. It doesn't make a distinction between frontend and backend, or worker jobs.
You can run your frontend, backend, admin code base as Cloud Run service.
Next to these you setup Cloud SQL for your operational database, and connect the Cloud Run services with the Cloud SQL connector so they are able to use for read/write queries.

Hosting Web application - best practices

So I have a web application where the Frontend is written in React and the backend is written in NodeJs/NestJs, and are in the stages of deploying the application. I have a Linode server running Ubuntu, and my initial thoughts was to install Docker & Kubernetes (I will need a couple more servers) and then spin up containers for the front and backend, and a separate server hosting the database. Since the requirements are high uptime, scaleability and modularity.
So is this a good way to go about setting up the application? Are there any pros and cons with this setup except pricing because of the amount of servers needed? Or are there any other options available that could be more benefitial?
Thanks in advance.
It depends if you want to make DevOps job or not, and also about the budget you have.
If you really want to stay in control of your clusters, scalability of them and money is not a worry, then kubernetes is a good alternative.
Disclaimer: I don't know Linode and have no idea if there is some GCP compatible services.
For front-end, you said it was react: The hosting service of firebase, here's a tutorial.
And the good news is that you can alternatively use any cloud platform with a storage service like Google Storage, AWS S3 or Azure.
For back-end, I would suggest App Engine or functions, I'm having a great experience using App Engine and is a lot easier to configure than any pods, deployments, ingress and all steps to deploy a kubernetes cluster. I'm not really sure if you can use NestJs with Cloud Functions and all FaaS options.
Also, this suggestion will make you spend a lot less than a whole k8s infrastructure.
But, of course, it depends on your case.

Specify Zone for Google Cloud App Engine Flexible Environment

Question:
Is there a way to Specify Zone for Google Cloud App Engine Flexible Environment to reside in? If not, what are the alternatives?
Context:
I'm having a setup where I use App Engine to write and reads to Bigtable. However I noticed a performance decrease, and during the debugging, I found a documentation from Google stating:
There are issues with the network connection. Network issues can reduce throughput and cause reads and writes to take longer than usual. In particular, you'll see issues if your clients are not running in the same zone as your Cloud Bigtable cluster.
In my case, my client is in a different region, by moving it to the same region had a huge increase in performance. However the performance issue still exist, and the recommendation from the documentation is to put client in the same zone as Bigtable.
I also considered using Container engine or Compute Engine where it is easier to specify the zone, but I want stay with App Engine for its autoscale functionality and managed services.
App Engine is a regional service:
App Engine is regional, which means the infrastructure that runs your
apps is located in a specific region and is managed by Google to be
redundantly available across all the zones within that region.
Taken from here.
You could indeed use GKE or GCE, while you're correct that these are not managed services like App Engine is, they do both support autoscaling.

Best way to cache in Google App Engine Node

In the google App Engine docs for Node.js it only recommends redis, for other languages it has native memcache. Is there a better caching system than making exterior calls to redis?
So far native memcache is only available to standard environment apps. But it's true, native memcache future availability on flex env was announced at least for python and java. From Memcache:
The Memcache service is currently not available for the App Engine
flexible environment. An alpha version of the memcache service will be
available shortly. If you would like to be notified when the service
is available, fill out this early access form.
Please note that the Redis service comes in 2 flavours:
redis
memcached
Both of these services can be provided right from inside google datacenters, in which case they don't exactly make outside calls. From Setting up (on either service):
... Be sure to specify GCE/us-central1 as the Cloud for the lowest latency
This means they shouldn't differ too much in performance compared to the native memcache, which is also offered on some (other) servers in the google datacenters. Well, at least for GAE apps hosted in us-central1.
Note: this is all based on docs, I didn't yet use the flex environment.
Like #Dan says Memcache is not available (yet) for Node.js
If you need to cache Datastore entities, there is a library (nsql-cache-datastore) that has a memory cache and can connect to a Redis db. Its "memory" cache store is only useful if you have one App engine instance.

Cloud Computing Terminology - IaaS , PaaS & SaaS

I went over a number of questions in Stackoverflow & on the web , which were very very useful. I had few questions on what I've read so far with regards to IaaS , PaaS & SaaS. However I have a lot of questions which may be very naive as I haven't seen any of these in action.
1) Is PaaS equivalent of a development environment where a software is developed / customized as opposed to IaaS which is an execution environment to run the developed the software (could be any env test or production)?
2) In case of PaaS , I saw apprenda as an example. As part of Apprenda , I saw .net , Java , IIS & SQL Server listed as part of platform. Does this mean that instead of having to install all these on my local machine or development box , I get to have a sort of remote machine where all the development tools are installed and I just have to go and program whatever I want to?
3) If I have not subscribed to IaaS for instance , how can I run the software developed using the platform that is exposed as a service?
4) I also read that PaaS can either be public or private (within company's firewall). If it is private , will the provider of PaaS basically set of up the platform for development on my company's infrastructure?
5) Can any website that provides be a capability to login be termed as SaaS? Eg: GMAIL , Yahoo Mail , Facebook etc.
6) Can Google Drive , Apple iCloud etc be termed as SaaS?
PAAS : Platform as a Service
You don't care about the underlying hardware or OS.
You only care about your code, the platform takes care of the rest
Scaling is done for you
You have to adhere to some restrictions imposed by the platform
Pay for what you use (more traffick, storage used -> higher bill)
examples are Google AppEngine, Heroku, AWS Elastic Beanstalk
IAAS : Infrasctructure as a Service
You rent infrastructure where you choose the amount of memory, CPU, disk size, OS, ...
You setup the runtime environment will full choice from NodeJs, Redis or LAMP stack or any flavor you can think of.
You are responsible for configuring the rented infrastructure for high availability and scaling out
More freedom but more configuration (devops)
Pay for what you allocate (You setup your machines and choose your infrastructure beforehand)
examples are Google Compute Engine, Amazon EC2
But the world isn't that black and white. PaaS and IaaS grow towards each other. For example AppEngine managed VMS give you more freedom in choosing your underlying OS while still in a PaaS environment. And Google Autoscaler or Kubernetes brings managing your infrastructure to a more declarative level.
Finally SaaS products are oriented towards non-technical end users. So Apple iCloud, Google Drive, Gmail, Yahoo webmail are examples of SaaS.
I try to provide simpler answer and mapping with Azure deployment model
SaaS: Software as a service.
It's simplest, easiest, fastest method to host your web app/service into cloud.
Your web will be deployed automatically into some VMs and autoscale when needed.
You don't need to care about the VMs. Cloud provider will maintain them.
SaaS in Azure: Azure App Services (or Web App/Websites).
PaaS: Plafform as a service.
Cloud provider will create the pre-configured VMs which install all prerequisites (Ex: Windows Server 2012 with .Net 4.5 and IIS installed). These VMs will autoload your sites/apps when it's completely spin-off.
PaaS almost identical to SaaS except it allows you can remote desktop connect to the VMs, do some configuration tasks on there such as run custom startup scripts...
PaaS in Azure: Azure Cloud Services. Azure provides 2 kind of preconfigured VMs. They are Web Roles if you need host the website and Worker Roles if you need run background process.
IaaS: Infrastructure as a service.
Cloud provider will provide you dedicated VMs so you have full control to do any customization you want (you can customize the OS to the services and software...). It just like the VMs on-premises.
It's suitable if your app need to do a lot of customizations on the hosting environments to run.
IaaS in Azure: Azure Virtual Machines
The NIST definition of Cloud Services in general is a great place to start when looking for answers.
It gives the 5 characteristics of Cloud Services:
Broad Network Access
On-demand Self Service
Resource Pooling
Rapid Elasticity
Measured service
And then talks about service models, which are SaaS, PaaS and IaaS.
Simply running your app in the cloud is not sufficient to say it's SaaS. So, it's not just apps being targeted at non-technical users, it's apps that cover those characteristics. A sub-point to resource pooling above is providing some sort of multi-tenanted capability when delivering the solution to users.
1) Is PaaS equivalent of a development environment where a software is developed / customized as opposed to IaaS which is an execution environment to run the developed the software (could be any env test or production)?
A PaaS solution does not have to be a development environment. It can provide the resource for some software being developed, without the developer needing to provision all the underlying facilities to enable the delivery of that resource. Eg, SQL Azure is a PaaS that lets developers have access to a relational DB service. The developer can write and invoke queries against it, without having to stand up SQL Server instances themselves.
2) In case of PaaS , I saw apprenda as an example. As part of Apprenda , I saw .net , Java , IIS & SQL Server listed as part of platform. Does this mean that instead of having to install all these on my local machine or development box , I get to have a sort of remote machine where all the development tools are installed and I just have to go and program whatever I want to?
It should mean that you have access to the remote resources that your development tools can connect to and manage. The server (say SQL server) is not the same as the tool you use to access it, say SQL Server Management studio.
3) If I have not subscribed to IaaS for instance , how can I run the software developed using the platform that is exposed as a service?
You can't.
4) I also read that PaaS can either be public or private (within company's firewall). If it is private , will the provider of PaaS basically set of up the platform for development on my company's infrastructure?
A private PaaS means that a company has setup private infrastructure to allow developers to use a resources that are part of the architecture of a solution that do not need to be managed by the developers themselves.
5) Can any website that provides be a capability to login be termed as SaaS? Eg: GMAIL , Yahoo Mail , Facebook etc.
No, not according to the NIST definition. Providing user login is not the same as enabling multi-tenancy. Simply put, if the app enables companies/teams with groups of users to use it, it's moving towards SaaS. So, think solutions like Slack, Gitter & Freshbooks.
6) Can Google Drive , Apple iCloud etc be termed as SaaS?
Google Drive as part of Google Apps for Business, yes.
Until you start seeing, "iCloud for business", no.

Resources