Please enable JavaScript.
Coggle requires JavaScript to display documents.
Serverless - Coggle Diagram
Serverless
DynamoDB
Features:
- Fully managed, HA with replication across 3 AZs
- NoSQL database
- Scales to massive workloads, distributed database
- Millions of requests per seconds, trillions of row, 100s of TB of storage
- Fast and consistent in performance (low latency on retrieval)
- Integrated with IAM for security, authorization and administration
- Enables event driven programming with DynamoDB Streams
- Low cost and auto scaling capabilities
- Amazon DMS can be used to migrate to DynamoDB (from Mongo, Oracle, MySQL, S3)
- Can launch a local DynamoDB on my computer for development purposes
- Delivers single-digit millisecond performance at any scale
- Can create one or more secondary indexes on a table and issue Query or Scan requests against these indexes
- DynamoDB TTL allows me to define a per-item timestamp to determine when an item is no longer needed. Shortly after the date and time of the specified timestamp, DynamoDB deletes the item from my table without consuming any write throughput. TTL is provided at no extra cost
DynamoDB Primer:
- Made of tables
- Each table has a primary key (must be decided at creation time)
- Each table can have infinite number of items (i.e. rows)
- Each item/ row has attributes (can be added over time and can be Null)
- Maximum size of item is 400KB
- Data types supported are:
- Scalar types: String, Number, Binary, Boolean, Null
- Document types: List Map
- Set types: String Set, Number Set, Binary Set
Provisioned Throughput:
- Table must have provisioned Read and Write Capacity Units
- Read Capacity Units:
- $0.00013 per RCU
- 1 RCU = 1 strongly consistent read of 4KB per second
- 1 RCU = 2 eventually consistent read of 4KB per second
- Write Capacity Units:
- $0.00065 per WCU
- 1 WCU = 1 write of 1KB per second
- Option to setup auto-scaling of throughput
- Throughput can be exceeded temporarily using Burst Credit
- Get a ProvisionedThroughputException if Burst Credit are empty
- It is then advised to do an exponential back-off retry
DynamoDB Streams (image)
Features:
- Create, Update, Delete operations in DynamoDB can end up in DynamoDB Stream
- Stream can be read by AWS Lambda. Use Cases:
- Reach to changes in real time (send welcome email to new uses)
- Analytics
- Create derivatives tables/ views
- Insert into ElasticSearch
- Can implement cross region replication with Streams
- Streams has 24 hours of data retention
DynamoDB DAX (image)
Features:
- Is a DynamoDB Accelerator
- Seamless cache for DynamoDB , no application re-write
- Writes go through DAX to DynamoDB
- Micro second latency for cached reads and queries
- Solves the Hot Key problem (too many reads)
- 5 minutes TTL for cache by default
- Up to 10 nodes in the cluster
- Multi-AZ (minimum 3 nodes recommended for production)
- Secure (encryption at rest with AWS KMS, VPC, IAM, CloudTrail)
Transaction
Features:
- All or nothing type of operations
- Coordinate Insert, Update, Delete across multiple tables
- Include to 10 unique items or up to 4MB of data
Global Tables (image)
Features:
- Cross Region Replication
- Active Active replication, multiple Regions
- Must enable DynamoDB Streams
- Useful for low latency, DR purpose
Capacity Planning
On-Demand
Features:
- No capacity planning needed (neither WCU/ RCU), scales automatically
- 2.5x more expensive than provisioned capacity
- Helpful when spikes are un-predictable or application is very low Throughput
Provisioned/ Planned capacity:
- Provision WCU and RCU
- Can enable auto scaling
Security
Features:
- VPC Endpoints available to access DynamoDB without internet
- Access fully controlled by IAM
- Encryption at rest using KMS
- Encryption in transit using SSL/TLS
-
Lambda
Features:
- Virtual functions (no server to manage)
- Limited by time (short executions - 15 mins max)
- Run on-demand
- AWS Lambda supports the synchronous and asynchronous invocation of a Lambda function
Pros:
- Automatic scaling
- Easy pricing
- Pay per request and compute time
- Free tier of 1,000,000 Lambda requests and 400,000 GBs of compute time
- Integrated with whole AWS suite of services
- Integrated with many programming languages
- Easy monitoring through CloudWatch
- Increasing RAM will also improve CPU and network
- Can provision Lambda functions with a maximum of 10 GB of memory
- Customers have access to up to 6 vCPUs. Helps compute intensive applications like machine learning, modelling, genomics, and HPC application perform faster
Support languages:
- Node.js
- Python
- Java
- C# (.NET core)
- Golang
- C#/ Powershell
- Ruby
- Custom Runtime API
- Lambda Container Image (only if implement the Lambda Runtime API)
Examples:
- Serverless Thumbnail creation (image)
- Serverless CRON Job example (image)
Pricing: (image)
- Pay per calls
- Pay per duration
Limits (per Region)
Execution Limits:
- Memory allocation: 128MB - 10GB (64MB increments)
- Maximum execution time: 900 seconds (15 minutes)
- Environment variables (4KB)
- Disk capacity in the function container (i.e. in /tmp): 512MB
- Concurrency executions: 1000 (can be increased upon request)
Deployment Limits:
- Lambda function deployment size (compressed zip): 50MB
- Uncompressed deployment size: 250MB
- Can use /tmp directory to load other files at startup
- Environment variables (4KB)
Features:
- Deploy Lambda functions alongside my CloudFront CDN
- More responsive applications
- Can customize CDN content
- Pay only for what I use
- Use Lambda to change CloudFront requests and responses (image)
- Viewer Request: after CloudFront receives a request from a Viewer
- Origin Request: before CloudFront forwards the request to the Origin
- Origin Response: after CloudFront receives the response from the Origin
- Viewer Response: before CloudFront forwards the response to the Viewer
- Can generate responses to Viewer directly without ever sending the request to the Origin
- Global applications example (image)
Use Cases:
- Website security and privacy
- Dynamic Web Application at the Edge
- SEO
- Intelligently Route Across Origins and DCs
- Bot Mitigation at the Edge
- Real-time image transformation
- A/B Testing
- User Authentication and Authorization
- User Prioritization
- User Tracking and Analytics
-
API Gateway (image)
Security
IAM Permissions (image)
Features:
- Create an IAM policy authorization and attach to User/Role
- API Gateway verifies IAM permissions passed by the calling application
- Good to provide access with your own infrastructure
- Leverages Sig v4 capability where IAM credential are in headers
-
-
-
Features:
- AWS Lambda + API Gateway, no infrastructure to manage (image)
- Support for the WebSocket Protocol
- Handle API versioning
- Handle different environments (DEV, SIT, UAT PRD)
- Handle security (authentication and authorization)
- Create API keys, handle request throttling
- Swagger/ Open API import to quickly define APIs
- Transform and validate requests and responses
- Generate SDK and API specifications
- Cache API responses
- Pay only for the API calls I receive and the amount of data transferred out
-
-
Cognito
-
-
Cognito Sync
Features:
- Synchronize data from device to Cognito
- Store preferences, configuration, state of app
- Cross device synchronization (any planform, IOS, Android)
- Offline capability (synchronization when back online)
- Requires Cognito Federated Identity Pools
- Store data in datasets (up to 1MB)
- Up to 20 datasets to synchronize
-
Serverless in AWS:
- Lambda
- DynamoDB
- Cognito
- API Gateway
- S3
- SNS, SQS
- Kinesis Data Firehose
- Aurora Serverless
- Step Functions
- Fargate
- CloudWatch event
- CloudFront
- Athena