Tutorial Dojo - DVA-C02 - Summary

Domain 1: Development with AWS Services

NoQA
I.1Improve performance of S3 uploadMultipart upload. How about Transfer Acceleration?
I.2Caching: Lazy-load & Write-through
I.3Lambda: Different parameter depends on environmentEnvironment variable (# Stage variable)
I.5API Gateway: same API Gateway for multiple environmentsStage variable
I.6CloudWatch Alarm: When to alarm?Period / Evaluation Periods / Data points to Alarm
I.7SAM: Nested applicationAWS::Serverless::Application
I.8Lambda deploy: Graduate increase traffic to new versionLambda supports traffic shifting for aliases (by setting traffic weight). (That’s why SAM have canary, linear deployment strategy )
I.9API Gateway: Map data for microservice (in container)Use HTTP integration (Not AWS or _PROXY)
I.10Database scale globally, handle frequent schema changesDynamoDB (not Aurora)
I.11API Gateway - TTL 300s. How client can invalidate cache?Send request with Cache-Control: max-age=0 header
I.13Session data store on DynamoDB. Delete session of logged out users?Use DynamoDB TTL (when will an item is eligible for expiration - in epoch time)
I.15Serve content based on location- CloudFront can add header about viewer location’s location (based on the viewer’s IP address).
I.16What to do after update Cfn template of a Lambda function?1. aws cloudformation package: Uploads local artifacts to S3, update Cfn template to reference these artifacts
I.17Multi-thread key-value cache storeElasticache for Memcached
I.19Process long-running tasksElastic Beanstalk worker environment (an HTTP request handler that EB invokes with an SQS queue)
I.20ECS: Where to config port for container?Task definition
I.22Can Lambda handle 10 requests/s (each request take 50s)500 concurrent execution (Lambda can handles without doing anything. The default limit is 1.000)
I.23DynamoDB table attributes: UserID (PK) - GameTitle (SK) - TopScore. Get max TopScore of each game?Create a Global Secondary Index: GameTitle (PK) - TopScore (SK). Query 1 item for each game in descending order.
I.24Kinesis Data Streams: How many worker is optimal to process a number of shards?1:1 ratio
I.25AWS CLI timeout when list bucket with 10.000 objectsAdd pagination parameter when use AWS CLI
I.26Permission to Create/Delete GitCommit reposcodecommit:CreateRepository & codecommit:DeleteRepository
I.27DynamoDB Streams: Send a copy of old item to S3StreamViewType: OLD_IMAGE
II.1RDS + Lambda + Translate text with Amazon Translate. Improve performance, reduce load to RDS?Use Lambda execution environment /tmp as cache store
II.2DynamoDB: Employee info. Which attribute use as primary key?employee_id
II.3Run a Lambda function every 30min?Use EventBridge Schedule Rule to create scheduled events -> target the Lambda function
II.4ECS integrate with API Gateway. Which integration make no intervention?HTTP_PROXY
II.5Which API to call to get permission (from a IAM Role) to interact with S3 APIAWS STS AssumeRole API (or AssumeRoleWithWebIdentity, AssumeRoleWithSAML) (optionally pass an SessionPolicy)
II.6Asynchronous invoke Lambda function with Invoke APIPass parameter InvocationType - Event
II.11DynamoDB: Write heavy - ProvisionedThroughputExceededException. Why?RCU/WCU of GSI is separate from base table
II.12CodeCommit: Permission to fetch, clone, pushcodecommit:GitPull, codecommit:GitPush
II.13Elastic Beanstalk: Deploy new version with CLIPackage app as zip/war file. Deploy with eb deploy (EB CLI is a different package. It’s not packaged with AWS CLI, not aws eb)
II.14Internal app: elastic, cost-effectiveDynamoDB, EC2 Spot Fleet
II.15Build an CI/CD to deploy to both EC2 & on-premise. Which service?CodeDeploy
II.16DynamoDB: 10 RCU, each item 4KB. How much read request/s the table can handle?10 RCU: 10 Strong Consistency Read - 20 Eventually Consistency Read
II.17Prototype microservices on ECS. Which task placement minimize cost?Binpack, random, spread
II.18Temporary AWS credential for both authenticated/unauthenticated. Which service?Cognito Identity Pool (Federated Identity)
II.20SQS: Duplicated messages. How to fix?For SQS, when call SendMessage API, add MessageDeduplicationId param
II.21DynamoDB: Protect from overwritten?Implement optimistic locking with version number (ensure update the right version item)
II.22Lambda: Asynchronous invoke, exponential back-off, then send un-processed messages to another service.Lambda supports Dead Letter Queue (just as SQS DLQ)
II.23Collect visitor click to ads. Which service?DynamoDB: Use UpdateItem to implement atomic counter (Approximately ~ Add 1 to previous value)
II.24DynamoDB: Read 100 items. Which API?BatchGetItem (instead of GetItem) then BatchWriteItem
II.25DynamoDB: Store recent updated item automatically1. DynamoDB Streams + Lambda (not recommend)
II.26DynamoDB: Session data. Reduce storage without using provision throughputUse DynamoDB TTL
II.27Kinesis Data Streams: How to handle data flow (Scaling)?1. Split shards to increase stream capacity; 2. Merge shards to decrease stream capacity.
II.28Kinesis Data Streams: Consumer process every other day & store to S3. S3 only has half of the data?Kinesis Data Streams default retention period is 24h (up to 365 days)
II.29An AWS account has 2 Lambda function. 1 works optimal, 1 is throttled. Why?The reserve concurrency execution of function 1 is higher
II.30Lambda: Process events from S3 Events. 10 events/s, each event takes 3s. How much concurrency?Concurrency: number of in-flight request AWS Lambda function is handling at the same time.
II.32Protect AWS APIs call with MFAMFA-enabled IAM users must call GetSessionToken and submit an MFA code that is associated with their MFA device.
II.34Website hosted on S3 bucket_A, make GET request to S3 bucket_B. API calls are blocked by browsers?Enable CORS on bucket_B
II.35Migrate repos from Github to CodeCommit1. Create repos on CodeCommit; 2. Clone repos from Github; 3. Push to CodeCommit repos
II.36Lambda: Increase CPU?By increase memory
II.37ECS: Integrate with X-Ray. How to provide more granular timing information?Use sub-segment
II.38Version control system. Which service?CodeCommit
II.39API Gateway: Non-proxy integration with Lambda. How to ensure consumer include a query string?Use method request
III.1Replace spreadsheet-based tracking system. DynamoDB.EDA: DynamoDB Streams + Lambda + SNS
III.2Collect real-time user dataKinesis Data Streams
III.4CodeCommit, CodeBuild, CodeDeploy, CodePipeline. A central dashboard?CodeStar
III.5Cfn: Reuse value from a stack?Outputs/Export & Fn::ImportValue
III.6Hundreds of thousands of reads/writes per second. Which database?DynamoDB
III.7DynamoDB: Bidding system.DynamoDB Streams + Lambda + Conditional Write
III.8DynamoDB: Query a single tableLSI (when create the table)
III.9DynamoDB: Throttled. Hot partition. Fix minimal effort?Refactor to evenly distribute between partitions; Retries with exponential backoff
III.10CodeCommit: Setup?1. Git credential - HTTPS (username/password); 2. SSH connection (SSH key-pair)
III.11DynamoDB: 1.5KB. Write 100 items/s. WCU 100 but throttled. Fix?Increase WCU to 200.
III.13SQS: Duplicate messageSQS FIFO + SendMessage with DeduplicationID
III.15ECS: Place task between AZs?Spread
III.17Sync user data without your backend.Cognito Sync (delegated use AppSync)
III.21SQS: Config Dead Letter QueueJust provide ARN of the queue to DeadLetterConfig
III.22Elastic Beanstalk: Web app process large number of items from DynamoDB. Overload. Easiest fix?Use Batch operations for Get, Put, Delete
III.23DynamoDB: Send welcome mail for new user. How?DynamoDB Streams + Lambda + SNS
III.24DynamoDB: Table - FighterID (PK) - FilterTitle (SK). Query by other attributes?Create a GSI
III.25DynamoDB: + Elasticache. Write data if cache miss. Improve?Add write-through + TTL
III.26Kinesis Data Streams: 100 shards, Lambda (10 seconds/request, 50 items/seconds)Maximum of 100 Lambda concurrency = number of shards
III.27Cfn: How to automate the process of getting latest AMI?Use System Managers Parameter Store
III.28SQS: Process tool long & messages appear twiceIncrease visibility timeout
III.29CloudFront: Slow to login & 504Authentication@Edge + Origin fail over
III.30Lambda: Increase CPU?By increasing memory
III.31API Gateway: Implement APIs form current Swagger spec.Just import the OpenAPI/Swagger file.
III.32Microservice using Docker + Fine-grain controlECS
III.33Quickly deploy Node app (provisioning, load balancing, ASG…)Elastic Beanstalk
III.34Amplify: config?amplify.yaml
III.35S3: Cross-Region Replication. Fail. Why?Maybe Object Versioning is not enable
III.36S3: Upload Terabytes of data from over the worlds. Slow. Improve speed?S3 Transfer Acceleration
III.37API Gateway: Reuse same function for different stage (different DynamoDB table)Stage variable + mapping template
IV.1Automatically watermark images uploaded to S3Use S3 Event Notification s3:ObjectCreate:Put. Send the event to Lambda function (destination) (# S3 Object Lambda)
IV.2Lambda function: access RDS in private subnetConnect to the VPC
IV.3API Gateway + Lambda: Map incoming request to integration request & vice versaAWS custom (Lambda custom)
IV.4Which cache strategy ensured cached data is always up-to-date & stale data are automatically deleted?Write-through + With TTL
IV.5DynamoDD: How to prevent data overwritten?Optimistic locking + Conditional writes (check version number)
IV.6Database credential: How to encrypted & auto-rotate?Use Secrets Manager + Enable Automatic Rotation
IV.7S3: Use SQL to filter & retrieve only a subset data of an object?S3 Select (supports CSV, JSON, Apache Parquet & compressed CSV, JSON)
IV.9DynamoDB - GSI: How much throughput to provision?GSI WCU >= Base table WCU
IV.10DynamoDB: 2KB items - 10 writes/s - 20 eventually consistent reads/s. How much RCU/WCU?2KB ➡️ 1 strongly consistent read = 1 RCU ➡️ 1 eventually = 0.5 RCU ➡️ 20 eventually = 10 RCU
IV.111 item = 17KB. 320 strongly consistent read/s. How much RCU?17KB/item ➡️ 5RCU/strongly consistent read ➡️ 320 strongly read = 320 x 5 = 1600 RCU
IV.12HTML, JS, image, video. How to server with lowest latency around the world?S3 + CloudFront
IV.13AI-based app built with Lambda. How to modify the way invocation event are read form Lambda runtime API?Use Lambda custom runtime
IV.14Migrate monolith on-premise app to Lambda. Best practice?1. Take advantage of execution runtime; 2. Use environment variable…
IV.16Online game - Sync app pref + state of player + Allow multiple player to share stateApp Sync (Cognito Sync not support shared data)
IV.17AWS CLI in EC2 instance. How to easily switch role?1. Create a new CLI profile with credential; 2. Run aws CLI with --profile
IV.18DynamoDB: Ensure item is updated only some attribute meets some conditionConditional writes
IV.19DynamoDB: Debug throughput of both base table & GSI when update item?Call UpdateItem with ReturnConsumedCapacity set to None / Total / Indexes
IV.20DynamoDB Streams: How to integrate with Lambda?1. Create an EventSourceMapping to poll the DynamoDB stream, read & process records
IV.21Serverless app: Which service can manage configuration & deploy the whole stack + simple?AWS SAM (Serverless Application Model)
IV.22DynamoDB: Table: ArticleName (PK) - Category (SK). Query ArticleName using another Sort Key + Strongly consistent readCreate a new table with Local Secondary Index (LSI). Migrate the existing data to new table (LSI cannot be created after the DynamoTB is created)
IV.23S3: Ensure all objects are encrypted with AE256Use bucket policy to deny any Create request doesn’t have x-amz-server-side-encryption: AE256 header
IV.24EC2: Shell script to get instance public/private IPUse Instance Metadata Service endpoint 169.254.169.254/latest/meta-data
IV.25Lambda: Account concurrency limit 2000; 10 functions: 1 function 400, 1 function 200. The rest, the third?The rest: 1400; the third: 1300.
IV.26Coordinate multiple services into serverless workflow. Which service?AWS Step Functions
IV.27API Gateway: Enable caching. How to invalidate 1 key?Send the request with Cache-Control: max-age=0
IV.28Lambda: Connection refused. Why?Maybe the invoke URL is wrong (http without s)
IV.29Lambda: Improve performance?Increase memory will increase CPU too.
IV.30Lambda: A function initialize DB connection every time it executes. How to optimize?Move the DB connection to shared execution context (outside handler)
IV.31Lambda: Can the function built with Rust?Yes. Use custom runtime
IV.32Lambda: A function fetch 20MB static data every time it executes. How to optimize?Place the initialize outside Lambda handler; saved external file to /tmp
IV.34Online game. How to add feature to cross-sync profile data between device?Use Cognito Sync (or App Sync)
IV.35DynamoDB: Which attribute to use as partition key?The partition should uniquely identify each item
IV.36CodePipeline: Push build details into a DynamoDB?Use EventBridge & Lambda
V.2API Gateway & Lambda: New version. Smooth migrationUpdate Lambda function -> Deploy new version. Specify new ARN in API Gateway integration. Redeploy to new stage.
V.3Elastic Beanstalk: Path of config file/.ebextensions/xxx.config
V.4Lambda: Ephemeral storage/tmp
V.5Lambda: How to use Ruby?Ruby’s natively support
V.6CloudFront: Update image immediatelyUse file name versioning
V.7Cognito: Authentication with JWT1. Create User Pools
V.9S3: Lowest costGlacier Deep Archive
V.10EC2: Run Apache web serverUse user-data to install and start Apache web server
V.11App host in 1 region. Re-create on other regions using AMI & CloudFormation. How?Use Cfn Mapping & FindInMap
V.12Serverless app. Application code & infrastructure code in Python. How?Use CDK and Python
V.13Step Functions: Handle error? Aggregate data in different states?Use Catch & ResultPath
V.15DynamoDB: Control access to individual items & attributes?Fine-grain access control with
V.16Cognito: UI for login page missing brand logoCognito allows customization for: logo, CSS.
V.17SQS queue: messages larger than 256KB.Use Amazon S3, (for Java) Extended Client Library
V.20API Gateway: Integrate a XML-based SOAP API. How?Use HTTP Integration:
V.21Serverless: Send newsletter at 7-day interval. How?Use EventBridge Schedule Rule to create events at 7-day interval, sends the events to Lambda function target
V.23DynamoDB: Group multiple actions to multiple items to a one-or-nothing operation?Use TransactionWriteItems
V.24DynamoDB: When an item added to Customer table, dynamically update Payment table. How do it in real time?Enable DynamoDB Streams for Customer table, trigger a Lambda function to update Payment table
V.25ALB: Obtain all value of identical query parameter key.Enable multi-value headers
V.26ECS: 2 containers share logs. How?Define these 2 containers in 1 task definition, use EFS as a volume

Domain 2: Security

NoQA
I.2Share DB endpointUse System Manager Parameter Store secure string
I.4API Gateway: Allow another account invoke via IAM Role1. From the other account, grant permission to interact with this API Gateway
I.5Grant permission to access only some path of a S3 bucketUse S3 bucket policy, with the policy statement Resource including the path
I.6Login with social site: Facebook…, then access to AWS serviceCognito Identity Pool (Federated Identity)
I.7S3 - Encrypt AE256x-amz-server-side-encryption: AE256
I.9KMS - Generate data key but not use immediatelyGenerateDataKeyWithoutPlaintext
II.1Cognito - Enforce MFA for suspicious login attemptUser Pool / Adaptive Authentication / Automatic risk response
II.2EC2 instance - Upload images to S3. How to give EC2 instance permission?IAM Role (Instance Profile)
II.3Dev needs to access Test/Prod accounts. How to give permission?Grant cross-account access:
II.4API Gateway - Lambda Authorizer: Implement one that same as OAuth, SAMLAPI Gateway - Lambda Authorizer (Custom Authorizer) has 2 types:
II.5EC2 instance has both credentials & Instance ProfileAWS CLI credentials precedence: CLI options > ENVVAR > Assumed Role > IAM Identity (/.aws/config) > Credential file (/.aws/credentials) > EC2 instance profile > Container credential
II.8S3 - Encryption using KMS-C. How to upload object?Include the headers: x-amz-server-side​-encryption​-customer- + algorithm/key/key-MD5
II.9IAM, SCP - How to test IAM policy?IAM Policy Simulator
III.1API Gateway: Lambda authorizer - accepts header, query stringsRequest parameter-based authorizer (REQUEST authorizer)
III.2On-premise KMS, migrate to AWS. Key is store in dedicated hardwareCloudHSM
III.3S3: Upload small file + Use KMS key: OK. Upload big file (100GB): not OKAWS CLI use multipart upload for big files. It’s required the kms:Decrypt permission
III.4S3: SSE with KMS (using default KMS key). Which header?- x-amz-server-side-encryption: aws:kms
III.5S3: SSE-C. How does it work?1. You manage key & give AWS the key each time you upload a file
III.6KMS: A file encrypted with data encryption key (DEK). How to decrypt the files locally?1. Use KMS’s Decrypt to decrypt the DEK
III.7CodeDeploy: Platform: ECS - appspec.yamlappspec.yaml for ECS needs: TaskDefinition, ContainerImage, ContainerPort
III.8Share DB connection endpointSystems Manager Parameter Store secure string
III.9SSL certificate from 3rd party. Which service can store?AWS Certificate Manager (for unsupported regions, use IAM certificate store)
IV.2SSM Parameter Store: Notify if param haven’t been rotated for 90 days1. Use Advanced tier / Parameter polices / Notification policies
IV.3S3: Ensure data is encrypted at rest using the company key1. Client-Side Encryption (CSE) - Encrypt the data before send to S3
IV.4KMS: Locally encrypt data (Envelope encryption)1. Use the GenerateDataKey API to get a data key.
IV.5API Gateway: Custom authorizer using bearer token (same as SAML, OAuth). How?Use API Gateway Lambda authorizer (aka custom authorizer)
IV.6Database credential + RotateSecrets Manager + Auto Rotation (How? Secrets Manager run a Lambda function )
IV.7CloudFormation: Retrieve license key + cost-effectiveSystems Manager Parameter Store + Secure String
IV.8Migrate on-premise to AWS. Integrate LDAP directory service (not compatible with SAML)Implement a custom identity broker, which use STS to issue short-live AWS credentials
IV.9Cognito: Additional authentication methodIntegrate Multi-Factor Authentication (MFA) to Cognito User Pool
IV.10SQL Server. Migrate to RDS. Encrypt data before write to disk & vice versa.Enable SQL Server Transparent Data Encryption
IV.11S3. Someone use your image without permission.(Block public access) Use pre-signed URL / pre-signed cookies
V.2S3 bucket in production account. How to allow a user on dev account access?1. In prod acc, create an IAM role
V.3S3. Which service to allow user register/sign-in & upload/access images on S3.Cognito User Pools & Identity Pools
V.4Allow temporary access to EC2 & but still enforce MFA? Which STS API?STS GetSessionToken
V.6API Gateway: Regulate access to API & charge based on usageUsage Plan
V.7Best practice to manage access keyRemote all access key of root account, use IAM role for applications
V.8Most secure way to send CW logs in EC2 instance of ASG launch configuration- Create a new IAM role for the new Launch Configuration
V.10S3: Hundreds of thousands of objects. Turn on SSE-KMS. Performance degradation. Why?Requests to KMS are exceeded quota
V.11How to check permission of an IAM role?1. Use IAM Policy Simulator

Domain 3: Deployment

NoQA
I.3Deploy Lambda with CodeDeployCodeDeploy deploy configuration:
I.4Build, test, deploy serverless appServerless Application Model (SAM)
II.1SAM: workflow redeploy1. sam build; 2. sam deploy
II.2Elastic Beanstalk: Dev/Test - Deploy ASAPEB deployment strategy: AllAtOnce
II.3SAM: deploy 10% every 10minSAM Linear 10min
II.4Lambda: package deployment take too much time to deploy? How increase deploy speed?Lambda package deployment quota (for a function) is 50 MB (zipped; includes runtimes, layer…)
II.6CloudFormation: Easiest way to deploy a hello_world lambda functionIncline the function in AWS::Lambda::Function Properties / Code / Zipfile
II.7Elastic Beanstalk: Upgrade from Java 7 to 8. Shift all traffic to the new one, revert if something’s wrongBlue/Green Deployment: EB AllAtOnce + EB swap environment URLs (EB will use Route 53 to swap CNAMEs)
II.8CodeDeploy: Deploy to where? How?CodeDeploy deploy configuration:
III.1EC2: EBS-backed root volume. How to detach the root-volume?Stop the EC2 instance, then detach the root volume
III.2Elastic Beanstalk: Maintain compute resource while deploying. No downtime.Rolling with additional batch, Immutable
III.3DynamoDB: 3.5KB. 150 eventually consistent reads/second. How many RCU?1 strongly read -> 1 RCU
III.4Lambda: Deployment package 80MB. What to do now?Split the dependencies to a layer
III.5SAM: How to use Cfn & include SAM?Use Cfn Transform & AWS:Serverless macro to process SAM template to Cfn template
III.7Cfn: Different accounts. How to manage update across all accounts?Use StackSets
IV.2Elastic Beanstalk: HA, revert quickly?1. Use any EB deployment strategy, e.g. All-at-once (fastest)
IV.3CloudFormation: Inline code in templateAWS::Lambda::Function / Code / ZipFile
IV.4Serverless app: Zip code, upload to S3, produce package deployment-ready template & deploysam deploy (which includes sam package)
IV.5CloudFormation: Install packages, start services on EC2 after provisionedcfn-init
V.1CodeDeploy: S3 source. Deploy to EC2 fail during DownloadBundleThe EC2 instance profile don’t have permission to access S3 bucket
V.3Deploy to 3 environments: test, staging, production. How?Use 3 deployment groups, each for 1 environment.
V.4Elastic Beanstalk: Multi-container Docker. Which file to configure container definitions?Dockerrun.aws.json
V.5Elastic Beanstalk: Multi developers deploy without upload the whole project?Use eb deploy to deploy from local CodeCommit repo
V.6Serverless app defined with CDK. Deploy to new account. NoSuchBucket error. Fix?Run cdk bootstrap to provision resources for CDK deployment, e.g. IAM role, S3 bucket.
V.8CodeCommit: Forgot to pull master. Fix conflict?git rebase feature branch on master branch. Then manually fix conflict.

Domain 4: Troubleshooting and Optimization

NoQA
I.1Move session data to AWS, 100% CPU, HAElastiCache for Redis
I.2sam local - Access denied1. aws configure --profile; 2. sam local invoke --profile
I.3Cost effective when using SQSLong polling (config ReceiveMessage WaitTime)
I.4Record all changes to a DynamoDB table to another oneDynamoDB Streams + Lambda (write to another DynamoDB table)
I.5DynamoDB - Reduce queriesDAX
I.8ECS store data in DynamoDB, how to verify each new items?DynamoDB Streams + Lambda
I.9API Gateway - 504504 Gateway timeout -> Integration timeout after 30s
I.10RDS - Too many connectionsRDS Proxy
I.11API Gateway timeout - Which CW metrics to watch?Latency, IntegrationLatency
I.13CloudFront - end-to-end SSLViewer Protocol Policy, Origin Protocol Policy: HTTPS
I.15Capture IP in/out of an VPCVPC Flow Log
I.16Elastic Beanstalk config for cron-jobcron.yaml
I.17DynamoDB - Fetch only some attributesUse projection attributes
I.18Lambda function download same big fileUse /tmp
I.21App deploy with Elastic Beanstalk - Config X-Ray.ebextensions/xray-daemon.config
II.1DynamoDB: ProvisionedThroughputExceededOptimize DynamoDB:
II.2X-Ray: View full trace without using consoleUse GetTraceSummaries, BatchGetTraces
II.3ECS + Docker app: How to setup tracing with X-Ray?- Run xray-daemon inside docker image
II.4AWS CLI - TimeoutUse pagination: --page-size (request less items) --max-items (show less items)
II.9X-Ray: From where, IP address is fetch?X-Forwarded-For header
III.2X-Ray: Insufficient permissions to use X-ray console to view service map, segments. Which manged policy?- AWSXrayReadOnlyAccess
III.3API Gateway: Fetch latest data without caching (using Cache-Control: max-age=0 header). Which permission?Resource-based policy for execute-api:InvalidateCache action
III.4DynamoDB: Streams, EventBridge + Lambda every 36 hours. Missing data?DynamoDB Streams retention period is 24 hour. Only last 24 hours data is available
III.5Kinesis Data Streams: Increasing data flow. Scale up?Split-shard + (increase numbers of worker)
III.6S3: CORS config: <AllowOrigin>, <AllowedMethod>, <AllowedHeader>, <MaxAgeSeconds>3600</MaxAgeSeconds>MaxAgeSeconds: time in seconds that your browser can cache the response for a preflight request
III.7API Gateway: Lambda. 504. No errors in CW. Why?Lambda function takes more than 30s (API Gateway timeout)
III.8RDS: Slow response (in peak time). Already optimize queries. Resolve?- Add Read Replica
III.9Latency-sensitive service. AWS Fargate, CloudFront, ALB. Too much unauthenticated users, increase CPU of Fargate. Fix?Use CloudFront Function (attach to Viewer Request) to authenticate users
III.10EC2: Monitor memory, swap. How?Install CW Agent
III.11Elastic Beanstalk: EC2. CW doesn’t show memory. Why?By default, CW doesn’t track EC2 instance memory
III.12Kinesis Data Steams: Producers restart -> Duplicate record. Fix?Call PutRecord with SequenceNumberForOrdering param.
IV.1Send traces to X-ray?Use X-Ray daemon (CloudWatch Agent can do this on EC2/On-Premise)
IV.2SQS: Duplicate message. Fix?Use FIFO queue + provide deduplicationID
IV.3X-Ray: Filter trace?1. Use web console; 2. Use GetTraceSummaries (support search)
IV.4X-Ray: Send trace to X-Ray?- 1. Use X-Ray SDK (through X-Ray daemon); 2. Use X-Ray/CLI (directly)
IV.5Kinesis: Over-provision. Scale in?Merge cold shards
IV.6API Gateway: Terminated Lambda. Why?- Lambda timeout: max 15min ➡️ terminated
IV.7API Gateway: No metrics for CacheHitCount/CacheMissCountAPI Gateway caching is not enabled
IV.8SQS injections, XSS attack. How to deal?Use Web Application Firewall (WAF). It works with: CloudFront, ALB, API Gateway (REST API)
IV.9Kinesis: 10 shards - 10 EC2 instance. Increase to 20 shards, how many instances?20 instances, the number of instances match the number of shards by 1:1 ratio
IV.10RDS: Monitor memory, CPU usages of processes?Use RDS enhanced monitoring
IV.11CodePipeline: Code review in each stage before move to next stageUse a “manually approval” action, and send the approval request to a SNS topic
IV.12X-Ray: Record call to DB, other services, SQL queries & filterAdd annotations in the subsegment section of the segment document.
IV.13X-Ray: Permission to send trace to X-Ray?AWSXRayDaemonWriteAccess
V.3CodeBuild: Run on a proxy server. RequestError when CodeBuild is accessed. Fix?
V.5S3 - Event Notifications: Compress the images, but it takes too much time. Improve?Increase memory ➡️ increase CPU
V.6Debug latency of your app (with recently added function)? How to do with X-Ray?Define sug-segments inside the function to “instrument” (measure) it
V.7AWS CLI: Create snapshot of EC2 instance. InvalidInstanceID.NotFound. Why?Maybe the AWS CLI is using a profile for a different region
V.8Build a CI pipeline. Which AWS services?CodeCommit, Lambda, CodeBuild
V.9Step Functions: Handle & recover from State’s exception.Use Catch & Retry fields in state machine definition
V.10Lambda - Cold start: Optimize?1. Reduce pre-handler code
V.11LAMP stack. Migrate to AWS?EC2 + Aurora/RDS
V.12Lambda: process file (5min). So slow?Change InvokeType to Event (asynchronous invocation)
V.14Website (hosted on S3) call API Gateway. No "Access-Control-Allow-Origin" error. Fix?Config CORS for API Gateway to allow the website (S3)
V.15API Gateway + Lambda: Publish a new version of AccService:Prod with the alias AccService:Beta. How to test before promote?Create a BETA stage. Use stage variable to reference the beta function alias
V.16Lambda: Unable to import module. Fix?1. Install the missing module locally.
V.17Elastic Beanstalk: Keep the old code in S3 bucket. How?Change Retention to Retain source bundle in S3