"jjj"
GCP In Compute Services
What Are GCP Compute Services?
GCP offers a mix of tools that allow workloads to run virtually across various infrastructures. These tools handle computing power, hosting logic, or executing scripts based on actions.
1. Compute Engine
Delivers virtual systems on request.
- Definition: Spin up machine instances with precise CPU, memory, and OS choices.
- Usage: Ideal for full control deployments (e.g., Linux/Windows environments).
- Sample Code (gcloud CLI):
gcloud compute instances create alpha-node \
--zone=asia-south1-c \
--machine-type=e2-medium \
--image-family=debian-11 \
--image-project=debian-cloud- Traits: Persistent disks, firewall setup, load distribution support.
2. App Engine
Hosts applications with automatic scaling.
- Definition: Upload code and let the environment scale automatically.
- Usage: Best for developers focusing on logic, not infrastructure.
- Example (Python app.yaml):
runtime: python310 Entrypoint: gunicorn -b :$PORT main:app
- Perks: Integrated security, traffic splitting, zero-ops scaling.
3. Cloud Functions
Triggers small snippets by events.
- Definition: Executes short routines without provisioning infrastructure.
- Usage: Handle file uploads, database changes, webhook requests.
- Python Example:
def greet_user(request): Return "Welcome to GCP!"
- Deploy Command:
gcloud functions deploy greet_user \
--runtime python310 \
--trigger-http \
--allow-unauthenticated - Benefits: Stateless, auto-scaled, pay-per-call execution.
4. Cloud Run
Wraps containers into fully managed services.
- Definition: Accepts Docker images and runs them serverlessly.
- Usage: Great for APIs, microservices, background jobs.
- Container Example:
FROM python:3.10 COPY app.py . CMD ["python", "app.py"]
- Deploy Command:
gcloud run deploy --source . --region us-central1 --platform managed
- Attributes: HTTP endpoint auto-exposed, scalable down to zero.
5. Kubernetes Engine (GKE)
Manages container clusters with Kubernetes.
- Definition: Automates orchestration of pods, services, and deployments.
- Usage: Enterprise-grade CI/CD pipelines, production container handling.
- Creation (CLI):
gcloud container clusters create dev-cluster \
--num-nodes=3 \
--zone=us-east1-b- Highlights: Node balancing, auto repair, rollout rollback.
6. Bare Metal Solution
Runs traditional workloads without virtualization.
- Definition: Dedicated hardware housed in Google's facility.
- Usage: Legacy software needing physical hardware.
- Features: Oracle DB support, minimal latency, hybrid architecture option.
Quick Comparison
| Service | Purpose | Control Level | Auto-scaling |
|---|---|---|---|
| Compute Engine | VM Infrastructure | High | Manual |
| App Engine | Code Deployment | Medium | Built-in |
| Cloud Run | Container Execution | Moderate | Dynamic |
| Cloud Function | Event-Driven Logic | Low | Built-in |
| GKE | Container Coordination | High | Clustered |
| Bare Metal | On-Prem Performance | Very High | External |
Example Use Case
E-commerce Store Setup
- UI hosted on App Engine
- Order processing in Cloud Functions
- Payment gateway via Cloud Run
- Stock management handled in GKE
- Batch jobs run with Compute Engine
Key Differences
- Compute Engine = Virtual Machines (manual control)
- App Engine = Hosted platform (abstracts infra)
- Cloud Run = Serverless for containers
- Cloud Functions = Stateless, reactive logic
- GKE = Container orchestration (K8s)
- Bare Metal = Dedicated physical nodes
Syntax Recap Summary
| Tool | Syntax Tool |
|---|---|
| Compute Engine | gcloud compute instances create |
| App Engine | app.yaml, deploy via gcloud app deploy |
| Cloud Function | Define Python, deploy via gcloud functions deploy |
| Cloud Run | Use Docker, gcloud run deploy |
| GKE | Cluster: gcloud container clusters create |
| Bare Metal | Reserved via Google sales team |
Prefer Learning by Watching?
Watch these YouTube tutorials to understand GCP Tutorial visually:
What You'll Learn:
- 📌 Ep.19 - Choosing The Right Compute Service on GCP
- 📌 Google Compute Engine Tutorial | Google Compute Services Overview | GCP Training | Edureka