All Cheatsheets

Cloud Computing

Cloud Computing

Cloud computing is the on-demand delivery of computing resources (servers, storage, databases, networking, software) over the internet, with pay-as-you-go pricing. Instead of buying and maintaining physical servers, you rent resources from a cloud service provider (CSP) and access them from anywhere.

Use Cases -
  • Web & App Hosting : Most websites and mobile app backends run on cloud servers instead of company-owned hardware.
  • Streaming : Netflix, Spotify, and YouTube deliver content from cloud infrastructure that scales with viewers worldwide.
  • File Storage & Sync : Google Drive, OneDrive, iCloud, and WhatsApp backups all store user data in the cloud.
  • AI & Machine Learning : Training and serving models like ChatGPT needs massive GPU clusters that only the cloud can provide on demand.
  • E-Commerce & Sales Spikes : Shopping platforms scale up for festival sales or flash sales and scale back down afterward.
  • Payments & Banking : UPI apps, payment gateways, and fintech services run on cloud infrastructure with fraud detection running in real time.
  • Remote Work & Collaboration : Google Docs, Microsoft Teams, Zoom, and Slack are cloud services used daily by distributed teams.
  • Backup & Disaster Recovery : Organizations replicate data to the cloud so a fire or hardware failure does not destroy it.
  • Gaming : Multiplayer game servers and cloud gaming services (Xbox Cloud Gaming, GeForce NOW) run gameplay in cloud data centers.
  • IoT : Smart devices (watches, cameras, sensors) send their data to cloud platforms for storage and analysis.
Problems Before the Cloud -
  • Running your own servers meant paying for hardware, energy, OS licenses, cooling, and a dedicated IT workforce. It was unwieldy and very expensive.
  • Each application typically used only a fraction of its server's capacity, so most of the hardware sat idle.
  • Different applications needed different framework or runtime versions, which made sharing a server difficult.
  • Every new business application usually meant buying a new physical server.

Virtualization solved the utilization problem by running multiple isolated machines on one server, and cloud providers built on that to rent out computing at massive scale.

Benefits of Cloud Computing -
  • Reduced Cost : Cuts both capital expenditure (CapEx: servers, data centers, cooling, failover systems) and operational expenditure (OpEx: maintenance, IT staff).
  • Pay As You Go : Resources are metered and you pay only for what you use, like a water or electricity bill.
  • Scalability : Scale resources up or down on demand, so you never run out of capacity and never pay for idle hardware.
  • Accessibility : Services can be accessed from virtually anywhere, at any time.
  • Business Continuity : Data is replicated and backed up, so a local crisis does not mean data loss.
  • Automatic Updates : The provider patches and upgrades the underlying platform.
  • Collaboration & Self-Service : Teams work on shared resources, and new resources can be provisioned in minutes through a portal or API without raising a ticket.
Risks of Cloud Computing -
  • Loss of Data or Services : An outage or account issue at the provider can take your services down.
  • Data Security : Your data lives on shared infrastructure that you do not physically control.
  • Compliance & Legal Risks : Local and international regulations (GDPR, HIPAA) restrict where and how data can be stored.
  • Cost Concerns : Pay-as-you-go can become expensive without monitoring and budgets.

Providers address these risks through SLAs (Service Level Agreements), which define guaranteed uptime, support response, and compensation when guarantees are missed.

Virtualization

Virtualization is the technology that lets one physical server run multiple isolated virtual machines, each with its own operating system and applications. It is the foundation of cloud computing. Apps appear to run on dedicated machines, but in reality they share the same physical server: App → VM → Hypervisor → Host OS → Server.

  • Virtual Machine (VM) : A software emulation of a complete computer, with virtual CPU, memory, disk, and its own guest OS. VMs are independent of the host hardware, so they can be moved between physical servers easily.
  • Hypervisor (VMM, Virtual Machine Monitor) : The software layer that creates and runs VMs, allocating the host's CPU, memory, and storage among them. It improves hardware utilization and reduces space, energy, and maintenance requirements.
  • VPS (Virtual Private Server) : A VM rented from a hosting provider. You get root access and a dedicated slice of a physical server at a fixed monthly price. Examples: DigitalOcean Droplets, Linode, AWS Lightsail.
Types of Hypervisors -
  • Type 1 (Native / Bare Metal) : Runs directly on the host hardware like a lightweight OS: Hardware → Hypervisor → Guest OS. Used in data centers and cloud platforms. Examples: VMware ESXi, Microsoft Hyper-V, Xen, KVM.
  • Type 2 (Hosted) : Runs as an application on top of a normal OS: Hardware → Host OS → Hypervisor → Guest OS. Used on desktops for testing and development. Examples: VirtualBox, VMware Workstation.
Containers vs VMs :

A VM virtualizes the hardware, so every VM carries a full guest OS along with the app and its dependencies. A container virtualizes at the OS level instead: containers share the host OS kernel and package only the application code and its dependencies. Example: Docker containers running on one Linux host, orchestrated at scale with Kubernetes.

Downsides of VMs -
  • Each guest OS wastes server resources (disk space, memory, processor).
  • Every OS needs licensing and admin time to keep it updated.
  • Booting a full OS makes VM startup slow.
Why Containers -
  • No guest OS per container, which saves disk, RAM, and CPU.
  • Containers start in seconds and many can run on the same machine.
  • The app and its dependencies ship together, so it runs the same everywhere (dev, test, production).

VMs still win when you need full OS isolation, different operating systems on one host, or stronger security boundaries. Cloud platforms actually run containers inside VMs to combine both.

Service Models

Service models define how much of the stack you manage versus how much the cloud service provider manages. The full stack, from top to bottom: Application, Data, Runtime, Middleware, OS, Virtualization, Servers, Storage, Networking. On-premise means you manage all of it.

  • IaaS (Infrastructure as a Service) :

    The provider gives you raw building blocks: virtual machines, storage, and networking. You install and manage everything from the OS up, such as hosting web applications or running your own SQL Server or Oracle installation. Also called Hardware as a Service (HaaS). Used by infrastructure and software development teams. Benefits: reduced financial risk (if a product launch fails, shut it down and stop paying), fast deployment, geographic reach, unlimited scalability. Examples: AWS EC2, Azure Virtual Machines, Google Compute Engine.

  • PaaS (Platform as a Service) :

    The provider manages the runtime, middleware, and OS as well; you bring only your application and data. It is a ready platform for software development, typically used for data-driven web apps (ASP.NET Core or Java with a managed database and web server). Benefits: everything IaaS offers, plus auto scaling, reduced development time, support for global teams, and multi-platform development. Examples: Azure App Service, AWS Elastic Beanstalk, Google App Engine, Heroku.

  • SaaS (Software as a Service) :

    The provider manages the entire stack and you just use the finished software through a browser or app, usually on a subscription. Used by individuals and organizations of every size for CRM, financial management, HR, billing, storage, and entertainment. Benefits: very easy to start, accessible anywhere, automatic updates, usage-based pricing. Examples: Office 365, Google Drive, Dropbox, Netflix.

  • CaaS (Containers as a Service) :

    The provider hosts and orchestrates your containers; you bring container images and the platform handles scheduling, scaling, and networking. It sits between IaaS and PaaS: more control than PaaS, less server management than IaaS. Examples: AWS ECS/EKS, Google Kubernetes Engine, Azure Kubernetes Service.

  • FaaS (Functions as a Service) :

    You deploy individual functions that run only when triggered by an event (HTTP request, file upload, queue message) and are billed per execution. This is the basis of serverless computing: no servers to manage and automatic scaling, including down to zero. Examples: AWS Lambda, Azure Functions, Google Cloud Functions, Cloudflare Workers.

  • BaaS (Backend as a Service) :

    The provider supplies ready-made backend features (database, authentication, file storage, APIs, realtime updates) that your frontend calls through an SDK. You write little or no backend code. Examples: Firebase, Supabase, AWS Amplify, Appwrite.

  • DBaaS (Database as a Service) :

    A managed database where the provider handles installation, backups, patching, replication, and scaling; you just connect and query. Examples: AWS RDS, Azure SQL Database, MongoDB Atlas, PlanetScale.

  • DaaS (Desktop as a Service) :

    A full virtual desktop streamed from the cloud, letting users access their work environment from any device. Examples: Azure Virtual Desktop, Amazon WorkSpaces.

  • XaaS (Anything as a Service) :

    The umbrella term for all such models, reflecting that nearly any IT capability (monitoring, security, storage, AI) can now be consumed as a metered cloud service.

Responsibility Breakdown :
Layer On-Premise IaaS PaaS SaaS
Application You You You CSP
Data You You You CSP
Runtime You You CSP CSP
Middleware You You CSP CSP
OS You You CSP CSP
Virtualization You CSP CSP CSP
Servers You CSP CSP CSP
Storage You CSP CSP CSP
Networking You CSP CSP CSP

Deployment Models

The deployment model defines who owns the cloud infrastructure and who can use it.

  • Public Cloud :

    The provider owns and maintains all the physical servers, storage, and networking, and rents them out to anyone. It is the most common model, managed through the provider's web portal, with multi-tenancy (multiple organizations share the same underlying resources) and pay-as-you-go billing. Examples: AWS, Microsoft Azure. Benefits: no upfront CapEx, no maintenance, highly scalable and reliable. Limitations: less visibility and control, compliance concerns. Fits fast-growing businesses, varying peak demands, and backup or disaster recovery solutions.

  • Private Cloud :

    Cloud infrastructure dedicated to a single organization (single-tenancy), located on-premise or hosted by a third party. The organization purchases the hardware and can customize everything. Benefits: better security and control, predictable costs, easier legal compliance. Limitations: limited scalability, huge initial CapEx, limited access. Fits government agencies, financial institutions, and other highly regulated businesses.

  • Hybrid Cloud :

    A combination of private and public cloud. Security-sensitive and business-critical workloads stay in the private cloud, while high-volume, lower-security workloads use the public cloud. With cloud bursting, an app runs in the private cloud under regular demand and bursts into the public cloud during spikes. Benefits: best of both worlds, better control, cost-effective. Limitations: added complexity, plus the public side's compliance and visibility concerns.

Multi-Cloud :

Multi-cloud means using services from more than one public cloud provider at the same time, for example running compute on AWS while using BigQuery on Google Cloud. It is different from hybrid cloud, which mixes private and public infrastructure. Organizations go multi-cloud to avoid vendor lock-in, pick the best service from each provider, meet regional or legal requirements, and survive a provider-wide outage. The cost is added complexity: separate billing, tooling, and skills for each provider.

Ownership Summary :
Type Location Tenancy Hardware Provided By
Private Cloud Inside org's corporate network Single-tenancy Organization
Public Cloud Anywhere on the internet Multi-tenancy Cloud Service Provider
Hybrid Cloud Corporate network + internet Single + Multi-tenancy Organization + CSP

Cloud Platforms & Infrastructure

A cloud platform is a provider's full suite of services: compute, storage, databases, networking, AI, and more, all managed from one console and API. Each provider offers equivalent core services under different names.

Major Providers -
  • AWS (Amazon Web Services, 2006) : The first and largest cloud platform with the widest service catalog. Key services: EC2 (virtual machines), S3 (object storage), RDS (managed databases), Lambda (serverless functions), CloudFront (CDN), VPC (networking).
  • Microsoft Azure (2010) : Second largest, strongest in enterprises already on the Microsoft stack (Windows Server, Active Directory, Office 365). Key services: Virtual Machines, Blob Storage, Azure SQL Database, Azure Functions, Azure DevOps, Entra ID (identity).
  • Google Cloud (GCP, 2013) : Strong in data analytics, Kubernetes (which Google created), and machine learning. Key services: Compute Engine (virtual machines), Cloud Storage, BigQuery (data warehouse), GKE (managed Kubernetes), Cloud Functions, Vertex AI.
  • Others : Oracle Cloud (enterprise databases), IBM Cloud (enterprise and AI), Alibaba Cloud (leading in Asia), DigitalOcean and Linode (developer-friendly, simpler pricing).
  • Infrastructure :

    In cloud terms, infrastructure means all the underlying resources an application needs: VMs, networks, load balancers, databases, DNS, and storage. Providers organize it into regions (geographic areas) and availability zones (isolated data centers within a region) so workloads can survive a data center failure.

  • Scalability :

    Scalability is a system's ability to handle growing load by adding resources. Vertical scaling (scale up) means moving to a bigger machine with more CPU and RAM; it is simple but has a hardware limit and usually needs downtime. Horizontal scaling (scale out) means adding more machines behind a load balancer; it has no practical limit and is the cloud-preferred approach, but the application must be built to run on multiple instances. Auto scaling adds or removes instances automatically based on metrics, for example an AWS Auto Scaling Group launching a new instance when average CPU stays above 70% and removing it when traffic drops.

  • Cloud Storage Types :

    Object storage stores files as objects with metadata, accessed over an HTTP API. It scales practically without limit and is the cheapest option, used for media, backups, logs, and static websites. Examples: S3, Azure Blob Storage, Google Cloud Storage. Block storage provides raw disk volumes attached to a VM with low latency, used for boot disks and databases. Examples: AWS EBS, Azure Managed Disks. File storage is a shared network filesystem (NFS/SMB) that many servers can mount at once, used for shared content and legacy applications. Examples: AWS EFS, Azure Files.

  • Infrastructure as Code (Terraform) :

    Infrastructure as Code (IaC) means defining infrastructure in version-controlled configuration files instead of clicking through a console. Terraform is the most popular IaC tool: you declare the desired resources in .tf files, and terraform plan shows what will change while terraform apply makes it real. It works across AWS, Azure, GCP, and many other providers. Alternatives: AWS CloudFormation, Pulumi, Ansible.

    resource "aws_instance" "web" { ami = "ami-0abcdef123" instance_type = "t3.micro" }
  • Site Reliability Engineering (SRE) :

    SRE is the discipline of running systems reliably at scale by applying software engineering to operations. Key ideas: SLIs (measured indicators like latency and uptime), SLOs (target values for those indicators), error budgets (allowed unreliability; if the budget is spent, new releases pause), and automating away repetitive manual work (toil). Monitoring, alerting, and incident response are the day-to-day tools.

  • Cloud Migration Strategies :

    Ways to move an existing application from on-premise to the cloud, in increasing order of effort. Rehost (lift and shift): move the app as-is onto cloud VMs; fastest, but gains little cloud benefit. Replatform (lift, tinker, and shift): make small optimizations while moving, such as switching the database to a managed one like RDS. Refactor / Re-architect: redesign the app to be cloud-native (microservices, containers, serverless); most effort, most benefit. The remaining options from the "6 Rs": Repurchase (drop the app and buy a SaaS product instead), Retire (shut it down), and Retain (leave it on-premise for now).

Backend Hosting & BaaS

Modern platforms sit on top of the big clouds and remove most deployment work. They fall into two groups: hosting/runtime platforms, where you write the backend yourself and they just run it, and Backend-as-a-Service, where the backend itself is provided.

Backend-as-a-Service (BaaS) -

A BaaS provides ready-made backend features: database, authentication, APIs, file storage, and often realtime updates. You write mostly frontend code and call their SDK. It is very fast to build with, but the platform remains a permanent part of your backend, so switching later is hard.

  • Firebase : Google's BaaS with Firestore (realtime NoSQL database), Auth, Cloud Storage, and Cloud Functions. Popular for mobile and rapid prototypes.
  • Supabase : Open-source Firebase alternative built on PostgreSQL, with auth, auto-generated REST APIs, realtime subscriptions, and storage.
  • AWS Amplify : Amazon's BaaS layer that wires AWS services (Cognito auth, DynamoDB, S3, AppSync GraphQL) into a frontend-friendly toolkit with hosting.
  • Appwrite : Open-source, self-hostable BaaS with database, auth, storage, and functions, available as a cloud service too.
  • PocketBase : A tiny open-source BaaS in a single executable (SQLite database, auth, file storage, realtime). Great for small projects and prototypes.
  • Nhost / Back4App : Other open-source-based BaaS options; Nhost pairs PostgreSQL with a GraphQL API, Back4App builds on the Parse framework.
Hosting / Runtime Platforms -
  • GitHub Pages : Free static site hosting straight from a GitHub repository. Best for docs, portfolios, and project pages. No backend code runs here.
  • Cloudflare Pages / Workers : Pages hosts static sites and frontends on Cloudflare's CDN; Workers run serverless code at the edge, close to users. Note: Workers is a runtime (FaaS), not a BaaS, because you still write the backend code yourself. Cloudflare only blurs the line by offering storage add-ons (KV, D1, R2) that Workers can use.
  • Vercel : Frontend-focused platform by the creators of Next.js. Git push deploys, preview URLs per pull request, and serverless/edge functions for API routes.
  • Netlify : Static site hosting plus serverless functions, with build automation, forms, and redirects. Similar space to Vercel.
  • Render : Runs full web services, static sites, cron jobs, and databases from a Git repo. A common home for React/Next.js apps with a real backend.
  • Railway : Deploys apps and databases from a repo or Dockerfile with minimal configuration. Good when you want Docker-based services without managing servers.
  • Firebase Hosting : Fast static hosting that pairs with Cloud Functions, so one project serves the site and its backend APIs.

Rule of thumb: static site only, use GitHub Pages, Netlify, or Cloudflare Pages. Frontend with API routes, use Vercel or Netlify. Full backend or Docker, use Render or Railway. Standard backend features without writing a backend, use Firebase or Supabase.

Cloud Security

Cloud security follows the Shared Responsibility Model. The provider is responsible for security of the cloud: physical data centers, hardware, networking, and the virtualization layer. You are responsible for security in the cloud: your data, user identities, access permissions, and service configuration. Most cloud breaches come from the customer side, typically misconfiguration such as a public S3 bucket or leaked access keys.

How the Split Shifts by Service Model -
  • IaaS : You also secure the OS, runtime, and applications on your VMs, including patching them.
  • PaaS : The provider takes over OS and runtime security; you secure your application, data, and access.
  • SaaS : The provider secures almost everything; you manage your data, users, and account settings.

In every model, data, identities, and access control remain your responsibility. Moving to the cloud can still improve security overall, since providers offer mature tooling that most organizations could not build themselves.

Core Practices -
  • Encryption : Encrypt data at rest (stored on disk) and in transit (TLS/HTTPS). Cloud services offer this as a built-in option, often with managed keys.
  • Two-Factor Authentication : Require a second factor beyond the password for console and account access, especially for admin accounts.
  • Auditing : Log every action taken on the account (who did what, when) using services like AWS CloudTrail, and review the logs for unusual activity.
  • Key & Credential Hygiene : Review access keys regularly, rotate them on a schedule, remove unused credentials, and grant the least privilege needed for each user or service.