SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
SERVICE-ORIENTED
ARCHITECTURE
By Samantha Geitz
LET’STALK ABOUT A PROJECT
(A HYPOTHETICAL ONE)
THE API ENGINEER
THE PROJECT
SOUNDS SIMPLE, RIGHT?
LET’S DO IT IN LARAVEL!
THE ENTITIES
• Users
• Admins
• Shirts
• Images
• Orders
• Shipping
• Payment Methods
• (Blog) posts
• Comments
• Mugs
• Laptop Stickers
• 3rd-party prices
• Search indexing
• Customer Service
• Reviews
• Videos
• ???
• 16 entities means (at minimum):
• 16-22 database tables
• 80-160 classes
• 800-1600+ unit tests
• A routes file that makes you want to
throw your computer out of a window
AND IF SOMETHING BREAKS,
IT ALL GOES DOWN
THIS IS A
MONOLITH
Keep building on top
of the project you
already have
SO WHAT IS
SERVICE-ORIENTED
ARCHITECTURE?
Lots of little separate
pieces (that talk to
each other when they
need to)
BOTH APPROACHES HAVE
THEIR PROS AND CONS
Just don’t do this
LET’S LOOK ATTHIS AGAIN
• Users
• Admins
• Shirts
• Images
• Orders
• Shipping
• Payment Methods
• (Blog) posts
• Comments
• Mugs
• Laptop Stickers
• 3rd-party prices
• Search indexing
• Customer Service
• Reviews
• Videos
• ???
SO WHAT MIGHTTHIS LOOK
LIKE USING SOA?
• Users
• Admins
Users API
• Shirts
• Images
• Mugs
• Laptop Stickers
• Reviews
Products API
• (Blog) posts
• Comments
• Videos
News API Orders API
• Orders
• Payment
Methods
• Customer
Service
• Shipping
Price Collector
• Price collecting
• Add prices to
product API
Search API
• Search indexing
• Search results
MICROSERVICES
• APIs organized around business capability /
function
• Only call other APIs when needed
• Single-responsibility principle
THE GOOD!
• Less code = easier to onboard new developers
• Fewer merge conflicts
• Easier to make changes and upgrades
• Improved fault isolation
• Running the test suite is far quicker
• Easier to scale and load-balance servers
THE BAD :(
• Deployment / Dev Ops complexity
• Cost
• Time investment for new microservices
• Shared code between projects can be a hassle
• More planning required
SO HOW DO I ACTUALLY
BUILD USING SOA?
LARAVELVS. LUMEN
• Lumen is great if you are building:
• APIs
• Small worker services (such as the search indexer)
• Use Laravel if:
• You don’t want to manually install front-end niceties like Elixir or
Bootstrap
• You know you’ll be using packages that don’t support Lumen
• You want/need Symfony’s more powerful routing component
• You’ve never built a Laravel application before
MAKINGYOUR
MICROSERVICES PLAY NICE
• Build APIs with a standard formatting schema
• JSON API / JSend / Other — just be consistent!
• Standardize HTTP codes / errors
• APIs call ONLY the endpoints they need using cURL or Guzzle
• Front-end clients (JavaScript application or Laravel project with
Blade templates) call endpoints they need
EXAMPLE
• Order API needs user info to print shipping label
• Send GET request to http://user-api.artisanalswag.com/
api/v1/user/{id} with user ID
• Check for API response
• If 200, return user
• If 400 / 404 / 500 / etc., pass along error message
AUTHENTICATION
• A few problems:
• How do you know what user is logged in?
• How do you keep unauthorized users out?
• Can you share session data? Should you?
USE OAUTH2!
• Authentication should be *stateless*
• You send user credentials to an authentication endpoint in User
API (along with client ID and secret)
• User API sends back two things — access token and refresh token
• Access token — short expiration time
• Refresh token — longer expiration time
• You send access token in header with your API requests
• User API confirms access token is still valid
• If access token is expired, the client should
send refresh token instead
• If refresh token is still valid, User API sends new
tokens (and deletes old ones)
• If refresh token is expired, require user to log
in again
SCOPES
• OAuth2 supports scopes (client permissions)
• Different clients can have different scopes
• Use with roles to protect your APIs
LOCAL DEVELOPMENT
• Homestead for local
• All software you need to run Laravel is included
• Same versions as your team / Forge
• List all applications in Homestead.yaml and hosts file
• Database — local or remote?
DEPLOY
• Laravel Forge
• Your Dev Ops guy
• Same cost no matter how many projects
• Taylor Otwell support
• Continuous integration (Travis, Codeship, etc.)
• Envoyer
AREYOU SAYING
MONOLITHS ARE BAD?
No! Do what makes sense for your application.
QUESTIONS?
Twitter: @samanthageitz
Email: samanthamichele7@gmail.com

Weitere ähnliche Inhalte

Ähnlich wie Service-Oriented Architecture

API Gateways are going through an identity crisis
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisis
Christian Posta
 

Ähnlich wie Service-Oriented Architecture (20)

apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
apidays LIVE Paris 2021 - Lessons from the API Stewardship Journey in Azure b...
 
Lessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptxLessons learned on the Azure API Stewardship Journey.pptx
Lessons learned on the Azure API Stewardship Journey.pptx
 
APIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidadAPIs distribuidos con alta escalabilidad
APIs distribuidos con alta escalabilidad
 
SGCE 2015 REST APIs
SGCE 2015 REST APIsSGCE 2015 REST APIs
SGCE 2015 REST APIs
 
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularEscaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
 
Azure Functions Real World Examples
Azure Functions Real World Examples Azure Functions Real World Examples
Azure Functions Real World Examples
 
Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)Swagger APIs for Humans and Robots (Gluecon)
Swagger APIs for Humans and Robots (Gluecon)
 
Tech Talk on Cloud Computing
Tech Talk on Cloud ComputingTech Talk on Cloud Computing
Tech Talk on Cloud Computing
 
Building a REST API for Longevity
Building a REST API for LongevityBuilding a REST API for Longevity
Building a REST API for Longevity
 
#SPSNYC 2018 Migrate your custom components to the #SharePoint Framework #SPFX
#SPSNYC 2018 Migrate your custom components to the #SharePoint Framework #SPFX#SPSNYC 2018 Migrate your custom components to the #SharePoint Framework #SPFX
#SPSNYC 2018 Migrate your custom components to the #SharePoint Framework #SPFX
 
(ATS6-DEV02) Web Application Strategies
(ATS6-DEV02) Web Application Strategies(ATS6-DEV02) Web Application Strategies
(ATS6-DEV02) Web Application Strategies
 
Serverless Meetup - Event Sourcing
Serverless Meetup - Event SourcingServerless Meetup - Event Sourcing
Serverless Meetup - Event Sourcing
 
Platforms FTW!
Platforms FTW!Platforms FTW!
Platforms FTW!
 
Platforms FTW!
Platforms FTW!Platforms FTW!
Platforms FTW!
 
Integrate Applications into IBM Connections Cloud and On Premises (AD 1632)
Integrate Applications into IBM Connections Cloud and On Premises (AD 1632)Integrate Applications into IBM Connections Cloud and On Premises (AD 1632)
Integrate Applications into IBM Connections Cloud and On Premises (AD 1632)
 
code talks Commerce: The API Economy as an E-Commerce Operating System
code talks Commerce: The API Economy as an E-Commerce Operating Systemcode talks Commerce: The API Economy as an E-Commerce Operating System
code talks Commerce: The API Economy as an E-Commerce Operating System
 
Build Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJSBuild Modern Web Apps Using ASP.NET Web API and AngularJS
Build Modern Web Apps Using ASP.NET Web API and AngularJS
 
Scaling
ScalingScaling
Scaling
 
API Gateways are going through an identity crisis
API Gateways are going through an identity crisisAPI Gateways are going through an identity crisis
API Gateways are going through an identity crisis
 
Application Insights for Integration Developers
Application Insights for Integration DevelopersApplication Insights for Integration Developers
Application Insights for Integration Developers
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Service-Oriented Architecture

  • 2. LET’STALK ABOUT A PROJECT (A HYPOTHETICAL ONE)
  • 5. SOUNDS SIMPLE, RIGHT? LET’S DO IT IN LARAVEL!
  • 6. THE ENTITIES • Users • Admins • Shirts • Images • Orders • Shipping • Payment Methods • (Blog) posts • Comments • Mugs • Laptop Stickers • 3rd-party prices • Search indexing • Customer Service • Reviews • Videos • ???
  • 7. • 16 entities means (at minimum): • 16-22 database tables • 80-160 classes • 800-1600+ unit tests • A routes file that makes you want to throw your computer out of a window
  • 8. AND IF SOMETHING BREAKS, IT ALL GOES DOWN
  • 9. THIS IS A MONOLITH Keep building on top of the project you already have
  • 10. SO WHAT IS SERVICE-ORIENTED ARCHITECTURE? Lots of little separate pieces (that talk to each other when they need to)
  • 11. BOTH APPROACHES HAVE THEIR PROS AND CONS Just don’t do this
  • 12. LET’S LOOK ATTHIS AGAIN • Users • Admins • Shirts • Images • Orders • Shipping • Payment Methods • (Blog) posts • Comments • Mugs • Laptop Stickers • 3rd-party prices • Search indexing • Customer Service • Reviews • Videos • ???
  • 13. SO WHAT MIGHTTHIS LOOK LIKE USING SOA? • Users • Admins Users API • Shirts • Images • Mugs • Laptop Stickers • Reviews Products API • (Blog) posts • Comments • Videos News API Orders API • Orders • Payment Methods • Customer Service • Shipping
  • 14. Price Collector • Price collecting • Add prices to product API Search API • Search indexing • Search results
  • 15. MICROSERVICES • APIs organized around business capability / function • Only call other APIs when needed • Single-responsibility principle
  • 16. THE GOOD! • Less code = easier to onboard new developers • Fewer merge conflicts • Easier to make changes and upgrades • Improved fault isolation • Running the test suite is far quicker • Easier to scale and load-balance servers
  • 17. THE BAD :( • Deployment / Dev Ops complexity • Cost • Time investment for new microservices • Shared code between projects can be a hassle • More planning required
  • 18. SO HOW DO I ACTUALLY BUILD USING SOA?
  • 19. LARAVELVS. LUMEN • Lumen is great if you are building: • APIs • Small worker services (such as the search indexer) • Use Laravel if: • You don’t want to manually install front-end niceties like Elixir or Bootstrap • You know you’ll be using packages that don’t support Lumen • You want/need Symfony’s more powerful routing component • You’ve never built a Laravel application before
  • 20. MAKINGYOUR MICROSERVICES PLAY NICE • Build APIs with a standard formatting schema • JSON API / JSend / Other — just be consistent! • Standardize HTTP codes / errors • APIs call ONLY the endpoints they need using cURL or Guzzle • Front-end clients (JavaScript application or Laravel project with Blade templates) call endpoints they need
  • 21. EXAMPLE • Order API needs user info to print shipping label • Send GET request to http://user-api.artisanalswag.com/ api/v1/user/{id} with user ID • Check for API response • If 200, return user • If 400 / 404 / 500 / etc., pass along error message
  • 22. AUTHENTICATION • A few problems: • How do you know what user is logged in? • How do you keep unauthorized users out? • Can you share session data? Should you?
  • 23. USE OAUTH2! • Authentication should be *stateless* • You send user credentials to an authentication endpoint in User API (along with client ID and secret) • User API sends back two things — access token and refresh token • Access token — short expiration time • Refresh token — longer expiration time • You send access token in header with your API requests
  • 24. • User API confirms access token is still valid • If access token is expired, the client should send refresh token instead • If refresh token is still valid, User API sends new tokens (and deletes old ones) • If refresh token is expired, require user to log in again
  • 25. SCOPES • OAuth2 supports scopes (client permissions) • Different clients can have different scopes • Use with roles to protect your APIs
  • 26. LOCAL DEVELOPMENT • Homestead for local • All software you need to run Laravel is included • Same versions as your team / Forge • List all applications in Homestead.yaml and hosts file • Database — local or remote?
  • 27. DEPLOY • Laravel Forge • Your Dev Ops guy • Same cost no matter how many projects • Taylor Otwell support • Continuous integration (Travis, Codeship, etc.) • Envoyer
  • 28. AREYOU SAYING MONOLITHS ARE BAD? No! Do what makes sense for your application.