Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Microservices & Cloud Networking
CN

Microservices & Cloud Networking

How modern cloud apps communicate: Master gRPC, REST, and the basics of VPCs and Security Groups.

REST vs gRPC

FeatureRESTgRPC
FormatJSON (text)Protocol Buffers (binary)
TransportHTTP/1.1 or HTTP/2HTTP/2
ContractOpenAPI spec (optional).proto file (required)
Code genManualAuto-generated from .proto
StreamingNo (server-sent events possible)Native (unary, server, client, bidirectional)
Browser supportNativeLimited (needs gRPC-web)

gRPC is 7-10x faster than REST for internal service-to-service communication due to binary serialization and HTTP/2 multiplexing.

Service Mesh (e.g., Istio)

A dedicated infrastructure layer for handling service-to-service communication:

  • Sidecar proxy (Envoy) runs alongside each microservice
  • Handles: service discovery, load balancing, retries, mTLS, observability
  • Developers write business logic; the mesh handles networking

Cloud Networking Concepts

VPC (Virtual Private Cloud)

An isolated virtual network within a cloud provider. You define:

  • CIDR block (e.g., 10.0.0.0/16)
  • Subnets (public = internet-facing, private = internal only)
  • Route tables (where traffic goes)
  • Internet Gateway (connects public subnets to the internet)
Internet

[Internet Gateway]

[Public Subnet 10.0.1.0/24] ← Load Balancer, Web servers

[NAT Gateway]

[Private Subnet 10.0.2.0/24] ← Database servers

Security Groups vs NACLs

Security GroupNACL
ScopeInstance levelSubnet level
StateStateful (auto-allows return traffic)Stateless (must allow both directions)
RulesAllow onlyAllow and Deny
EvaluationAll rules evaluated togetherRules evaluated in order (lowest number first)

Q: Why is gRPC faster than REST?

A: (1) Protocol Buffers are binary — smaller (3-10x) and faster to parse than JSON. (2) HTTP/2 multiplexing lets many requests share one connection without head-of-line blocking. (3) Strong typing in .proto files eliminates parsing ambiguities.

Q: Difference between Security Groups and NACLs?

A: Security Groups are stateful (allow inbound → auto-allow outbound) and operate at the instance level. NACLs are stateless (must explicitly allow both directions) and operate at the subnet level. Security Groups support allow-only; NACLs support both allow and deny.

Q: What is a VPC?

A: Your own private network segment in the cloud. You define the IP range, subdivide into public/private subnets, and control routing. It’s like having your own data center with complete control over network topology.

Q: What problem does a service mesh solve?

A: It moves networking concerns (retries, service discovery, encryption, observability) out of application code into a sidecar proxy. Developers write business logic; the mesh handles the rest consistently across all services.

My Private Notes

Notes are auto-saved locally to this device.