Share
Embed
Transcript
38 slides
-
© 2020, Amazon Web Services, Inc. or its Affiliates. Petra
Novandi Barus Senior Developer Advocate, AWS Indonesia Deploying Laravel Microservice App using Serverless Container AWS User Group Surabaya @petrabarus -
© 2020, Amazon Web Services, Inc. or its Affiliates. Glad
to meet you all! My name is Petra Novandi Barus 8 years happy customer of AWS ❤ Startups, DevOps, App Dev, Distributed Systems 2011 CTO & Co-founder, UrbanIndo.com 2016 Largest real-estate portal in Indonesia 2018 Acquired by 99.co (SG) 2018 Country CTO, 99.co Indonesia 2019 Developer Relations, AWS twitter.com/petrabarus t.me/petrabarus Contact -
© 2020, Amazon Web Services, Inc. or its Affiliates. Agenda
- Containers - Microservices - Serverless - Amazon ECS - AWS Fargate - PHP on Containers - Demo -
© 2020, Amazon Web Services, Inc. or its Affiliates. Common
Problem: It worked on my machine, why not in prod? Local Laptop Staging / QA Production On-Prem v6.0.0 v7.0.0 v4.0.0 v7.0.0 -
© 2020, Amazon Web Services, Inc. or its Affiliates. The
Problem • Different application stacks • Different hardware deployment environments • How to run all applications across different environments? • How to easily migrate from one environment to another? Static website Web fronted Background workers User DB Analytics DB Queue Dev VM QA Server Single Prod Server Onsite Cluster Public Cloud Team laptop Customer Servers -
© 2020, Amazon Web Services, Inc. or its Affiliates. Container
Solution • Unit of software delivery • Lightweight, portable, consistent • Deploy and run everywhere • Deploy and run anything • Bridge between dev and ops Static website Web fronted Background workers User DB Analytics DB Queue Dev VM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor’s laptop Customer Servers -
© 2020, Amazon Web Services, Inc. or its Affiliates. Basic
Concepts and Definitions Completely independent Monolith Microservices Miniservices ? -
© 2020, Amazon Web Services, Inc. or its Affiliates. Original
Monolithic Application - example Load Balancer Browser Database Webserver Data Access Service • On-premises • Tightly coupled application components • Load balancer • Relational Database App Service Visualization Service -
© 2020, Amazon Web Services, Inc. or its Affiliates. Hard
to Scale Can’t Handle Component Failures Slow Deployment Process Limited options Monolithic applications - limitations -
© 2020, Amazon Web Services, Inc. or its Affiliates. Microservices
architectures Mobile client Client IoT API Gateway Account DB Shipping DB Inventory DB Store Front Web App Account Lookup Shipment Query Inventory Query -
© 2020, Amazon Web Services, Inc. or its Affiliates. Challenge
Managing Multiple Containers Mobile client Client IoT API Gateway Account DB Shipping DB Inventory DB Store Front Web App Account Lookup Shipment Query Inventory Query -
© 2020, Amazon Web Services, Inc. or its Affiliates. Can’t
fit a monolith inside Lambda Lambda function Webserver Data Access Service App service Visualization Service Integration services InfoSec services APIs APIs APIs APIs Hooks Hooks Logging Monitoring Limitations: • Memory • Storage • Package size • Environment variables -
© 2020, Amazon Web Services, Inc. or its Affiliates. What
is serverless? No infrastructure provisioning, no management Automatic scaling Pay for value Highly available and secure -
© 2020, Amazon Web Services, Inc. or its Affiliates. AWS
Lambda AWS Fargate Amazon API Gateway Amazon SNS Amazon SQS AWS Step Functions COMPUTE DATA STORES INTEGRATION Amazon Aurora Serverless Amazon S3 Amazon DynamoDB AWS AppSync -
© 2020, Amazon Web Services, Inc. or its Affiliates. Amazon
Elastic Container Service -
© 2020, Amazon Web Services, Inc. or its Affiliates. Scheduling
and Orchestration Cluster Manager Placement Engine ECS -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential Without Fargate, you end up managing more than just containers EC2 Instance ECS Agent Docker Agent OS -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential - Patching and Upgrading OS, agents, etc. - Scaling the instance fleet for optimal utilization -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential Amazon Elastic Container Service -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential Amazon Elastic Container Service AWS Fargate run serverless containers -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Amazon Confidential Your containerized applications Managed by AWS No EC2 Instances to provision, scale or manage Elastic Scale up & down seamlessly. Pay only for what you use Integrated with the AWS ecosystem: VPC Networking, Elastic Load Balancing, IAM Permissions, CloudWatch and more AWS Fargate -
© 2019, Amazon Web Services, Inc. or its Affiliates. All
rights reserved. Picking a Compute Platform: Containers vs. Lambda -
© 2020, Amazon Web Services, Inc. or its Affiliates. Containerized
PHP Best Practices -
© 2020, Amazon Web Services, Inc. or its Affiliates. Best
Practices - Stateless / Share Nothing - Decouple Processes Into Multiple Containers - Never Store External Configuration Inside Container -
© 2020, Amazon Web Services, Inc. or its Affiliates. Stateless
/ Share Nothing Process Local filesystem / memory only for short cache Store sessions/asset/data in centralized • File/Asset → S3 • Sessions → DynamoDB • PHP store session in local by default → Linux: /tmp/sess_xxxxxx • Use AWS PHP SDK session store • Database → RDS/DynamoDB • Cache → Elasticache -
© 2020, Amazon Web Services, Inc. or its Affiliates. Decouple
Processes Into Multiple Containers - ”One concerns per container” ~ Docker - Benefits - Reusability - Security & Isolation - Easy to Monitor and Debug -
© 2020, Amazon Web Services, Inc. or its Affiliates. Never
Store External Configuration Inside Container - Container should be able to run in multiple environment - Store configurations in - Environment Variables - Parameter Store - Secrets Manager -
© 2020, Amazon Web Services, Inc. or its Affiliates. ECS
Service Discovery -
© 2020, Amazon Web Services, Inc. or its Affiliates. Demo
Link: - https://github.com/petrabarus/aws-sample-laravel-microservices - https://github.com/petrabarus/aws-sample-php-container-ecs -
© 2020, Amazon Web Services, Inc. or its Affiliates. Thank
You! @petrabarus