Using Service Discovery and
Service Proxy
A Simple Microservices Example
2
Monolithic application Microservices
Scaling Scaling
Moving from Monolithic Applications to Microservices
Microservices:
are an architecture style, in which
large complex software applications
are composed of one or more services
can be deployed independently of
one another and are loosely coupled
should be small and focused on
completing a single task
typically communicate through
language-neutral APIs like an
Hypertext Transfer Protocol (HTTP)-
based resource API using REST
Benefits of Microservices for Developers
• Enables you to avoid working on large code bases
• Easier to maintain or add to features
• Use existing skills, or the most optimal language
• Improves deployment and load times in your development tools
• Makes debugging easier
• Enables teams to work more independently of each other
• Simplifies tracking code dependencies
• Enables complete ownership by a self-contained single team, from
definition through development, deployment, operations, and sunseting
• Makes it easier to address performance bottlenecks
3
Service Discovery, Service Proxy and Microservices
4
• Service Discovery enables developers to easily
register and find instances of their microservices
Service
Proxy
Service
Proxy
Service
Proxy
Rules
Service
Proxy
Rules
Service
Discovery
Service
Discovery
Client codeClient code
Service
A
Service
A
Service
B
Service
B
Service CService C
Service Registration
Heartbeats
Requests
Locate
service
Rules
to apply
Call requested
services using
rules
• Service Proxy automatically balances workloads
across instances to improve performance
Together, these two services provide essential capabilities for
creating and using microservices
A Simple Microservices example
5
Maureen
DevOps Pro
Maureen has an online store
application with a front end that
generates a web UI, and a backend that
checks the inventory to see if items are
out of stock.
Her original design was a single
monolithic application but she has
decided to redesign it with a
microservices based architecture to
improve scalability, reliability, and
business agility. She’s going to
split her app into three services –
WebUI, Inventory and Database.
Monolithic
WebUI + Inventory +
Database
WebUI
Inventory
Before: Monolithic app After: Using microservices
Database
Service Discovery – Automates Service Registration
6
Let’s assume Maureen’s new architecture is
container based so each instance of a service will
be run in a container.
A key task in transitioning to a microservices
architecture is to register each instance of a
service.
Service Discovery automatically
-Registers each instance of a service
-Makes it easy to find instances of services once
registered
-Periodically checks the health of each service
Inventory
Helper Script:
Register
(“Inventory
Instance 1”)
Helper Script:
Register
(“Inventory
Instance 2”)
Helper Script:
Register
(“Inventory
Instance 3”)
Service
Discovery
Service Discovery – Finding Instances Easily
7
Once instances of services are registered,
Service Discovery makes it easy to find them.
Service Discovery provides a simple REST based
API to find instances by logical name.
Without Service Proxy, its up to the client code to
determine which instance from the list to call.
For example you could call the first instance
returned.
Web UI
Service
Discovery
Query(“Inventory”)
Response:
“Inventory Instance 1”,
“Inventory Instance 2”,
“Inventory Instance 3”
Web UI
Call “Inventory Instance 1”()
Inventory
1
2
1
2
Return response of
“Inventory Instance 1”()
Service Proxy – Microservices Load Balancing
8
Service Proxy automatically balances workload across active instances
Service Proxy calls Service Discovery under the covers and then performing basic load
balancing of instances through a round robin process without the client writing code.
Service Proxy also logs the performance of the microservices it proxies, allowing you to track
the performance of your microservices without the client writing code.
Web UI
Service
Proxy
CallProxy(“Inventory”) Service
Discovery
Query(“Inventory”)
Response:
“Inventory Instance 1”,
“Inventory Instance 2”,
“Inventory Instance 3”Inventory Call “Inventory Instance 2”()
based on round robin.
And log its processing time
Return response of
“Inventory Instance 2”()
1
2
1
2
Service Proxy – Making your solution more reliable
Service Proxy also lets Maureen improve the
quality of her app by making it easy to inject
delays and failures during testing without writing
code
Injecting delays will help Maureen simulate
performance bottlenecks
Injecting failures will help her test how well the
application recovers from various error situations
Web UI
If WW Inventory
request takes more
than 120 ms, switch to
Regional Inventory
instead
WW
Inventory
Regional
Inventory
Service
Proxy
Configure Proxy to Inject
delays to WW Inventory
to simulate WAN delays
Web UI
If Inventory is
not available,
use Local
Cache
InventoryService
Proxy
Configure Proxy to fail
some calls to Inventory
to simulate network
failure
Local
Cache
1
2
1
2
Service Proxy – Future Enhancement (Gremlin)
The initial public beta of Service Proxy will support two simple flavors of injection testing:
•Delays that are always injected through Proxy
•Failures that are randomly injected based through Proxy on a percentage (25% of the time,
50% of the time, etc…)
IBM Research has created a testing framework (Gremlin) that supports scripted orderly
testing via a recipe, and beyond beta we wish to extend Service Proxy to support integration
with this.
This will provide the capability to script specific failures for orderly resiliency testing that
helps clients to:
•Create repeatable sophisticated test cases via Gremlin recipes for delays, failures, and
scrambled communication across multiple microservices
•Separate synthetic testing load for testing instances from real user traffic running on
production instances
• Maureen:
– I just deployed a new version of the “WebUI” service. I want to make sure my
service can tolerate failures of other services and the environment.
• Release manager:
– I want to make sure each service is resilient to failures before a new version
release
11
Gremlin - simple use case
Inventory Database
Service
proxy
WebUI
Gremlin Vision
12
fault injection
rules
Not affected
Bluemix
Logging
Service
Logs
Synthetic Load
Real user traffic
Bluemix Tenant
Gremlin ServiceMaureen
Release
Manager
Scenario
Run
scenario Result What went wrong?
Service
Overload
❌
Inventory did not trigger
circuit breaker when DB
service was overloaded
Network
Instability
…
Service Status
WebUI
✅
Inventory ❌
Database ✅
LaunchLaunch
LaunchLaunch
Failure
Orchestratio
n
Behavior
Validation
Subjected to failures
Fallback
cache
Creating Your Own Gremlin Recipe
run_recipe.py topology.json gremlins.json checklist.json
BoundedRetries: Check if
WebUI retried its API calls to
RegionalInventory, no more
than 5 times, with 30ms gap
Fake “Overload”: Gremlin will intercept all
API calls to RegionalInventory
and return HTTP 503/429
Failure injected only if request has HTTP
header
“X-Gremlin-ID: delayTest-<val>”
Invitation to Join Our Beta Program
Interested in learning more? Join our beta program
Both Service Discovery for Bluemix and Service Proxy for Bluemix are in Beta in 1Q2016 and
available on the public Bluemix catalog: www.bluemix.net
For more information, contact
Doug Rothert, IBM Cloud Offering Manager
drothert@us.ibm.com
@DougRothert).
Notices and Disclaimers
15
Copyright © 2016 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission
from IBM.
U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM.
Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of
initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS DOCUMENT IS
DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE
USE OF THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT OR LOSS OF OPPORTUNITY. IBM
products and services are warranted according to the terms and conditions of the agreements under which they are provided.
Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice.
Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those
customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary.
References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries
in which IBM operates or does business.
Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials
and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant
or their specific situation.
It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and
interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such
laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law
Notices and Disclaimers Con’t.
16
Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not
tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products.
Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the
ability of any such third-party products to interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The provision of the information contained h erein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other
intellectual property right.
IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS, Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise Document Management System™, FASP®,
FileNet®, Global Business Services ®, Global Technology Services ®, IBM ExperienceOne™, IBM SmartCloud®, IBM Social Business®, Information on Demand, ILOG,
Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®,
PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, Smarter Commerce®, SoDA, SPSS, Sterling Commerce®,
StoredIQ, Tealeaf®, Tivoli®, Trusteer®, Unica®, urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business
Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM
trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
Thank You
Your Feedback is Important!
Access the InterConnect 2016 Conference Attendee
Portal to complete your session surveys from your
smartphone,
laptop or conference kiosk.

Using Service Discovery and Service Proxy

  • 1.
    Using Service Discoveryand Service Proxy A Simple Microservices Example
  • 2.
    2 Monolithic application Microservices ScalingScaling Moving from Monolithic Applications to Microservices Microservices: are an architecture style, in which large complex software applications are composed of one or more services can be deployed independently of one another and are loosely coupled should be small and focused on completing a single task typically communicate through language-neutral APIs like an Hypertext Transfer Protocol (HTTP)- based resource API using REST
  • 3.
    Benefits of Microservicesfor Developers • Enables you to avoid working on large code bases • Easier to maintain or add to features • Use existing skills, or the most optimal language • Improves deployment and load times in your development tools • Makes debugging easier • Enables teams to work more independently of each other • Simplifies tracking code dependencies • Enables complete ownership by a self-contained single team, from definition through development, deployment, operations, and sunseting • Makes it easier to address performance bottlenecks 3
  • 4.
    Service Discovery, ServiceProxy and Microservices 4 • Service Discovery enables developers to easily register and find instances of their microservices Service Proxy Service Proxy Service Proxy Rules Service Proxy Rules Service Discovery Service Discovery Client codeClient code Service A Service A Service B Service B Service CService C Service Registration Heartbeats Requests Locate service Rules to apply Call requested services using rules • Service Proxy automatically balances workloads across instances to improve performance Together, these two services provide essential capabilities for creating and using microservices
  • 5.
    A Simple Microservicesexample 5 Maureen DevOps Pro Maureen has an online store application with a front end that generates a web UI, and a backend that checks the inventory to see if items are out of stock. Her original design was a single monolithic application but she has decided to redesign it with a microservices based architecture to improve scalability, reliability, and business agility. She’s going to split her app into three services – WebUI, Inventory and Database. Monolithic WebUI + Inventory + Database WebUI Inventory Before: Monolithic app After: Using microservices Database
  • 6.
    Service Discovery –Automates Service Registration 6 Let’s assume Maureen’s new architecture is container based so each instance of a service will be run in a container. A key task in transitioning to a microservices architecture is to register each instance of a service. Service Discovery automatically -Registers each instance of a service -Makes it easy to find instances of services once registered -Periodically checks the health of each service Inventory Helper Script: Register (“Inventory Instance 1”) Helper Script: Register (“Inventory Instance 2”) Helper Script: Register (“Inventory Instance 3”) Service Discovery
  • 7.
    Service Discovery –Finding Instances Easily 7 Once instances of services are registered, Service Discovery makes it easy to find them. Service Discovery provides a simple REST based API to find instances by logical name. Without Service Proxy, its up to the client code to determine which instance from the list to call. For example you could call the first instance returned. Web UI Service Discovery Query(“Inventory”) Response: “Inventory Instance 1”, “Inventory Instance 2”, “Inventory Instance 3” Web UI Call “Inventory Instance 1”() Inventory 1 2 1 2 Return response of “Inventory Instance 1”()
  • 8.
    Service Proxy –Microservices Load Balancing 8 Service Proxy automatically balances workload across active instances Service Proxy calls Service Discovery under the covers and then performing basic load balancing of instances through a round robin process without the client writing code. Service Proxy also logs the performance of the microservices it proxies, allowing you to track the performance of your microservices without the client writing code. Web UI Service Proxy CallProxy(“Inventory”) Service Discovery Query(“Inventory”) Response: “Inventory Instance 1”, “Inventory Instance 2”, “Inventory Instance 3”Inventory Call “Inventory Instance 2”() based on round robin. And log its processing time Return response of “Inventory Instance 2”() 1 2 1 2
  • 9.
    Service Proxy –Making your solution more reliable Service Proxy also lets Maureen improve the quality of her app by making it easy to inject delays and failures during testing without writing code Injecting delays will help Maureen simulate performance bottlenecks Injecting failures will help her test how well the application recovers from various error situations Web UI If WW Inventory request takes more than 120 ms, switch to Regional Inventory instead WW Inventory Regional Inventory Service Proxy Configure Proxy to Inject delays to WW Inventory to simulate WAN delays Web UI If Inventory is not available, use Local Cache InventoryService Proxy Configure Proxy to fail some calls to Inventory to simulate network failure Local Cache 1 2 1 2
  • 10.
    Service Proxy –Future Enhancement (Gremlin) The initial public beta of Service Proxy will support two simple flavors of injection testing: •Delays that are always injected through Proxy •Failures that are randomly injected based through Proxy on a percentage (25% of the time, 50% of the time, etc…) IBM Research has created a testing framework (Gremlin) that supports scripted orderly testing via a recipe, and beyond beta we wish to extend Service Proxy to support integration with this. This will provide the capability to script specific failures for orderly resiliency testing that helps clients to: •Create repeatable sophisticated test cases via Gremlin recipes for delays, failures, and scrambled communication across multiple microservices •Separate synthetic testing load for testing instances from real user traffic running on production instances
  • 11.
    • Maureen: – Ijust deployed a new version of the “WebUI” service. I want to make sure my service can tolerate failures of other services and the environment. • Release manager: – I want to make sure each service is resilient to failures before a new version release 11 Gremlin - simple use case
  • 12.
    Inventory Database Service proxy WebUI Gremlin Vision 12 faultinjection rules Not affected Bluemix Logging Service Logs Synthetic Load Real user traffic Bluemix Tenant Gremlin ServiceMaureen Release Manager Scenario Run scenario Result What went wrong? Service Overload ❌ Inventory did not trigger circuit breaker when DB service was overloaded Network Instability … Service Status WebUI ✅ Inventory ❌ Database ✅ LaunchLaunch LaunchLaunch Failure Orchestratio n Behavior Validation Subjected to failures Fallback cache
  • 13.
    Creating Your OwnGremlin Recipe run_recipe.py topology.json gremlins.json checklist.json BoundedRetries: Check if WebUI retried its API calls to RegionalInventory, no more than 5 times, with 30ms gap Fake “Overload”: Gremlin will intercept all API calls to RegionalInventory and return HTTP 503/429 Failure injected only if request has HTTP header “X-Gremlin-ID: delayTest-<val>”
  • 14.
    Invitation to JoinOur Beta Program Interested in learning more? Join our beta program Both Service Discovery for Bluemix and Service Proxy for Bluemix are in Beta in 1Q2016 and available on the public Bluemix catalog: www.bluemix.net For more information, contact Doug Rothert, IBM Cloud Offering Manager drothert@us.ibm.com @DougRothert).
  • 15.
    Notices and Disclaimers 15 Copyright© 2016 by International Business Machines Corporation (IBM). No part of this document may be reproduced or transmitted in any form without written permission from IBM. U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM. Information in these presentations (including information relating to products that have not yet been announced by IBM) has been reviewed for accuracy as of the date of initial publication and could include unintentional technical or typographical errors. IBM shall have no responsibility to update this information. THIS DOCUMENT IS DISTRIBUTED "AS IS" WITHOUT ANY WARRANTY, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL IBM BE LIABLE FOR ANY DAMAGE ARISING FROM THE USE OF THIS INFORMATION, INCLUDING BUT NOT LIMITED TO, LOSS OF DATA, BUSINESS INTERRUPTION, LOSS OF PROFIT OR LOSS OF OPPORTUNITY. IBM products and services are warranted according to the terms and conditions of the agreements under which they are provided. Any statements regarding IBM's future direction, intent or product plans are subject to change or withdrawal without notice. Performance data contained herein was generally obtained in a controlled, isolated environments. Customer examples are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual performance, cost, savings or other results in other operating environments may vary. References in this document to IBM products, programs, or services does not imply that IBM intends to make such products, programs or services available in all countries in which IBM operates or does business. Workshops, sessions and associated materials may have been prepared by independent session speakers, and do not necessarily reflect the views of IBM. All materials and discussions are provided for informational purposes only, and are neither intended to, nor shall constitute legal or other guidance or advice to any individual participant or their specific situation. It is the customer’s responsibility to insure its own compliance with legal requirements and to obtain advice of competent legal counsel as to the identification and interpretation of any relevant laws and regulatory requirements that may affect the customer’s business and any actions the customer may need to take to comply with such laws. IBM does not provide legal advice or represent or warrant that its services or products will ensure that the customer is in compliance with any law
  • 16.
    Notices and DisclaimersCon’t. 16 Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products in connection with this publication and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. IBM does not warrant the quality of any third-party products, or the ability of any such third-party products to interoperate with IBM’s products. IBM EXPRESSLY DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The provision of the information contained h erein is not intended to, and does not, grant any right or license under any IBM patents, copyrights, trademarks or other intellectual property right. IBM, the IBM logo, ibm.com, Aspera®, Bluemix, Blueworks Live, CICS, Clearcase, Cognos®, DOORS®, Emptoris®, Enterprise Document Management System™, FASP®, FileNet®, Global Business Services ®, Global Technology Services ®, IBM ExperienceOne™, IBM SmartCloud®, IBM Social Business®, Information on Demand, ILOG, Maximo®, MQIntegrator®, MQSeries®, Netcool®, OMEGAMON, OpenPower, PureAnalytics™, PureApplication®, pureCluster™, PureCoverage®, PureData®, PureExperience®, PureFlex®, pureQuery®, pureScale®, PureSystems®, QRadar®, Rational®, Rhapsody®, Smarter Commerce®, SoDA, SPSS, Sterling Commerce®, StoredIQ, Tealeaf®, Tivoli®, Trusteer®, Unica®, urban{code}®, Watson, WebSphere®, Worklight®, X-Force® and System z® Z/OS, are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at: www.ibm.com/legal/copytrade.shtml.
  • 17.
    Thank You Your Feedbackis Important! Access the InterConnect 2016 Conference Attendee Portal to complete your session surveys from your smartphone, laptop or conference kiosk.

Editor's Notes

  • #3 Software is moving from traditional monolithic, on premise applications to a set of composable set of micro-services used in the cloud. Sometimes this is referred to as “born on the cloud” technology Why? New technology and process now promote rapid development cycles, built from creating smaller pieces of software that are hardened with automated testing. This software is also deployed with automated scaling and recovery, and has well defined interfaces to allow parts of the deployed solution to be redesigned or replaced without scrapping the entire investment. A key challenge with microservices is allowing developers to register their microservices, find their microservices, and control how their microservice is called through a proxy. By providing this capability as an on demand Bluemix service we reduce development cost, as well as operational costs by reducing the amount of code that development must write.
  • #6 Storefront and CheckInventory microservices instance of Service A registers themselves with Service Discovery through a helper script, automatically instance of Service B ADDS CODE to query Service Discovery and finds list of Service A instances, and grabs the first instance Then show that this can be refined with a load balancer through Service Proxy applied to Service A, there is no added code to Service B and that logging data will also show the transaction time then throw in the testing angle - delays and failures added to Service A through proxy without code changes
  • #7 Storefront and CheckInventory microservices instance of Service A registers themselves with Service Discovery through a helper script, automatically instance of Service B ADDS CODE to query Service Discovery and finds list of Service A instances, and grabs the first instance Then show that this can be refined with a load balancer through Service Proxy applied to Service A, there is no added code to Service B and that logging data will also show the transaction time then throw in the testing angle - delays and failures added to Service A through proxy without code changes
  • #8 instance of Service B ADDS CODE to query Service Discovery and finds list of Service A instances, and grabs the first instance Then show that this can be refined with a load balancer through Service Proxy applied to Service A, there is no added code to Service B and that logging data will also show the transaction time then throw in the testing angle - delays and failures added to Service A through proxy without code changes
  • #9 Then show that this can be refined with a load balancer through Service Proxy applied to Service A, there is no added code to Service B and that logging data will also show the transaction time then throw in the testing angle - delays and failures added to Service A through proxy without code changes
  • #10 Then show that this can be refined with a load balancer through Service Proxy applied to Service A, there is no added code to Service B and that logging data will also show the transaction time then throw in the testing angle - delays and failures added to Service A through proxy without code changes
  • #11 Then show that this can be refined with a load balancer through Service Proxy applied to Service A, there is no added code to Service B and that logging data will also show the transaction time then throw in the testing angle - delays and failures added to Service A through proxy without code changes
  • #15 Then show that this can be refined with a load balancer through Service Proxy applied to Service A, there is no added code to Service B and that logging data will also show the transaction time then throw in the testing angle - delays and failures added to Service A through proxy without code changes