3. 3
Who am I?
Robert is a Lead Consultant with Magenic, heading
up the Magenic Pivotal Practice, and has more than
15 years’ experience with the .NET and Microsoft
technologies. He has been working with Pivotal
Cloud Foundry in the .NET space for more than two
years, and during that time, Robert has led large re-
platforming and modernization efforts in moving
.NET applications to Pivotal Cloud Foundry. He also
has industry experience in real estate, financial
institutions, politics, and energy and chemical.
7. 7
Portfolio Rationalization
Inventory Analyze Catalog Backlog
• All applications
• Ancillary services
• All data sources
• Diagram the
system
• Decompose
functionality
• Catalog the
functionality of
each application
• Identifying
functionality that
crosses apps
• Determine if the
app is still used
• Determine its
business value
• Determine
suitability for the
cloud (SNAP)
• Backlog based on
app inventory and
functionality
catalog
• Organize based
on deprecation or
modernizations
8. 8
Conversational approach of
evaluating the suitability of
moving an app to the cloud.
» Flush out risks
» Outline priorities
» General understand of the
technologies used
» Understand relative sizing
SNAP
9. 9
» Overall for the app
» All of the deploy points
What to SNAP?
My App
Web UI
API 2
API 1
My App
XXL
Web UI
S
API 1
L
API 2
XXL
10. 10
» Event storming
› Workshop method used to understand domains in a system
› People
− Business: those who understand events in business process
− Technical: those who understand where the bodies are buried
› Stickies
− Orange: Events
− Blue: Commands
− Yellow: Aggregates
− Purple: trouble spots
› Select services
− Start small to prove out SDLC
− Then ramp up to higher value
Decomposition
11. 11
Event Storming
Customer Party
Size and Name
Recorded
What do we do
if no seats are
available?
Drinks Ordered
Food Ordered
Drinks Served
Order Queued Food Served
Food EatenFood Cooked
Food Staged
Bill Presented
Bill Paid
Order Drinks Queue Order Present BillRing BellSeat Requested
Customer
Seated
Pay Bill
What do we do
if payment is
declined?
13. 13
» Identifying and catalog functionality
for each application
› On such platforms like Confluence
» Evaluate proposed efforts against
any existing functionality
› Consider centralizing functionality if
possible that crosses applications
» Update the catalog frequently
Cataloging
15. 15
Is an open source framework of Cloud-native
libraries for implementing industry standard
best practices when building microservices
for the cloud.
» .NET Core and .NET Framework
» Runs on Windows and Linux
» Works with or without Pivotal Cloud Foundry
Steeltoe
16. 16
Configuration
Configuration enables developers to configure an application with values from a variety
of sources by using Configuration Providers. Each provider supports reading a set of
name-value pairs from a given source location and adding them into a combined multi-
level configuration dictionary.
17. 17
» Configuration Server
› Centralized configurations
› Served through Config Server
› Stored in Vault, GIT, or local file system
Spring Cloud Configuration Server
Java
App
.NET
App
Java
App
18. 18
» Add Cloud Foundry in Program.cs
» Configure Options in Startup.cs
» Inject in to your class
» Get values you need
Implementing Configuration Provider in .NET
public void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
services.ConfigureCloudFoundryOptions(Configuration);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[]
{
_applicationOptions.Application_Name,
_servicesOptions.Services["value"].ToString()
};
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.AddCloudFoundry()
.UseStartup<Startup>();
public ValuesController(IOptions<CloudFoundryApplicationOptions> applicationOptions,
IOptions<CloudFoundryServicesOptions> servicesOptions)
{
_applicationOptions = applicationOptions.Value;
_servicesOptions = servicesOptions.Value;
}
19. 19
Service Registration and Discovery
A service registry provides a database that applications can use to implement the
Service Discovery pattern, one of the key tenets of a microservices-based architecture.
Applications can use a service registry to dynamically discover and call registered
services.
20. 20
» Based on Netflix Eureka
» Centralized service registry
» Basic health checking
» Useful for container to container
(C2C)
Service Discovery
Consumer
Service
Registry
Producer
Producer
Producer
Producer
Producer
Register
Discover
Connect
21. 21
Implementing Service Discovery in .NET
» Client rewrites hostname portion
of URL with an actual service node
» Create a new Discovery Handler
» Call the service
DiscoveryHttpClientHandler _handler;
ILogger<AccountService> _logger;
private const string ACCOUNT_URL = "http://accountService/api/account";
public AccountService(IDiscoveryClient client, ILoggerFactory logFactory)
{
_handler = new DiscoveryHttpClientHandler(client,
logFactory.CreateLogger<DiscoveryHttpClientHandler>());
_logger = logFactory.CreateLogger<AccountService>();
}
public async Task<string> GetAccountName()
{
var client = GetClient();
var result = await client.GetStringAsync(ACCOUNT_URL);
_logger.LogInformation("AccountName: {0}", result);
return result;
}
private HttpClient GetClient()
{
var client = new HttpClient(_handler, false);
return client;
}
22. 22
Circuit Breaking
Cloud-native architectures typically consist of multiple layers of distributed services.
End-user requests may require multiple calls to these services, and failures in lower-
level services can spread to other dependent services and cascade up to the end user.
Heavy traffic to a failing service can also make it difficult to repair. By using Circuit
Breaker frameworks, you can prevent failures from cascading and provide fallback
behavior until a failing service is restored to normal operation.
23. 23
» Based on Netflix Hystrix
» Designed to prevent
cascading failures
» Gives live metrics on state
» Maintaining three states
» Used to fail gracefully and with
a known failure state
» Opens a circuit on
› Timeout
› failure
Circuit Breaker
Closed
Half-Open
Open
Trip breaker
Attempt
reset
Trip
breaker
Reset
24. 24
public class AccountCommand : HystrixCommand<Account>
{
private readonly ILogger<AccountCommand> _logger;
private readonly IAccountService _accountService;
private string _accountId;
public AccountCommand(IHystrixCommandOptions options, ILogger<AccountCommand> logger,
IAccountService accountService) : base(options)
{
_logger = logger;
_accountService = accountService;
}
public async Task<Account> GetAccount(string accountId)
{
_accountId = accountId;
return await Execute sync();
}
protected override async Task<Account> RunAsync()
{
return await _accountService.GetAccount(_accountId);
}
protected override async Task<Account> RunFallbackAsync()
{
_logger.LogError("Couldn't get account");
return await Task.FromResult(new Account());
}
}
» Extend HystrixCommand
» Add an Execute method
» RunAsync (Circuit Closed)
› What executes normally
» RunFallbackAsync (Circuit Open)
› What executes under failure
Implementing a Circuit Breaker in .NET
25. 25
Management
Both frameworks have a number of management endpoints that you can easily add to
your application. The way the endpoints are exposed and used depends on the type of
technology you choose in exposing the functionality of the endpoint.
26. 26
» Helps with monitoring and managing services in production
» Can be exposed via HTTP and integrate with Pivotal Apps Manager
» Customizable endpoints
› Settings
› Health
› Info
› Loggers
› Tracing
› etc.
Management
27. 27
» Quick way to check the
status of an application
» Customize to monitor
› Underlying services
› External services
› Messaging systems
» Used to tie in to existing
monitoring tools
Health Management
Service 3
Service 1
Health Check
OK
Health Check
Database is not
online
Database
28. 28
» Completely open source
» Active user community
› Dedicated Slack channel
› Open Pivotal Tracker
» Examples and sample code in GitHub
Open and Engaged
29. 29
» Using techniques to understand your portfolio of applications
» Get started sooner and in the correct place
» Use the tools to optimize applications to the cloud
Key Takeaways