START 19:25
dotnet 💙 K8s & Azure
Â
War Story, blood, thriller, etc.
Before we start
Survey
#0: who am I?
Piotr Stapp
- Unique name - just sing a song: "Don't Stapp me know" ;)
- CEO @ Dotnetomaniak
- VP @ devWarsztaty
- ex-Head architect @FinAi
- "Top secret" @ Allegro
- M.Sc (distction) Oxford Brooks University in Web Tech
- M.Sc. Warsaw University of Technology in Computer Science
- And ......
Survey result
#1: Let the journey begin
Architecture
- 50-70 micro-services (.NET + Python)
- .NET == .NET Framework (less) + dotnet core (more)
- Azure PaaS == Azure Application Service Environment on Windows (most) and on Linux (less)
- Azure Stuff == a lot of Azure components
Why K8s?
- New, shiny, hype, etc.
- Money (again)
- Well tested
- "Easy" to migrate
Why K8s? Why?
#2: dotnet 💙 Linux (memory)
Memory
Memory
Before
- Total 50-60 services
- App Service Plans (simplified calculation):
- RAM: 4 x 3.5GBÂ (in total 14GB)
- CPU: Dv2-Series compute equivalent (4 x ~2vCPU)
- 70-90% memory used
- From time to time reboot needed
After
- Total 30 services
- AKS with 4 DS2 v2 machines:
- RAM: 4 x 7GB (in total 28GB)
- CPU: 4 x 2vCPU (single machine has 2 virtual CPU)
- 100% memory used – dyingÂ
- Cannot install anything new - OutOfMemory
WTF per minute
- GC is important
- GC on Linux in docker has problems
- Java has problems too :)
- Temporary fix -> GC Server to GC Workstation
- Fixed (?) in dotNET 3.0
#3: dotnet 💙 Linux (time)
The code
var tzName = "Central Standard Time";
var tzi = TimeZoneInfo.FindSystemTimeZoneById(name);
Console.WriteLine(tzi.DisplayName);
The result
(UTC-06:00) Central Time (US & Canada)
Windows
Exception has occurred: CLR/System.TimeZoneNotFoundException
An unhandled exception of type 'System.TimeZoneNotFoundException'
occurred in System.Private.CoreLib.dll:
'The time zone ID 'Central Standard Time' was not found
on the local computer.'
Linux
Windows
Time Zones in the Windows registry
Â
All can be found at https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones
Linux
Time Zone database curated by the Internet Assigned Numbers Authority (IANA).
Â
All can be found at
https://www.iana.org/time-zones
Â
Solution?
- If, if, if - everywhere
- UTC only! - even for client
- NuGet - TimeZoneConverter
- NuGet - NodeTimeÂ
#4: dotnet 💙 Linux (WCF+WebServices)
WCF client only
- WCF Client for dotnet core - works!
- SOAP Auth (part) - NotImplementedException
- NuGet - NotFoundExpceptions
- StackOverflow - .....
What is SOAP?
- Set of HTTP Requests & Responses
- XML over HTTP
- Well described in W3C
- Java versus .NET == always a problem
How to solve
- Fiddler
- Docs
- HTTPClient
- XML parsing
Other options?
- Azure Function/Azure Web App
- Azure VM
- Other proxy
#5: dotnet 💙 Linux (other)
"Features"
- System.Drawing:
- Â up to 3.0 #@$#@$@#$@#%
- in 3.0+ don't know
- Microsoft Distributed Transaction Coordinator:
- nope
- redesign
- Performance counters:
- up to 3.0 - only in code
- in 3.0+ - new tools
#6: dotnet 💙 Linux (sum up)
#7: Azure 💙 AKS (Cosmos DB)
How to connect?
- Cosmos DB has 2 connections types:
- HTTP - slow
- TCP - fast
- Cosmos DB client + docker + AKS == NOPE
- dotnet core 3.1+ -> it works!
#7: Devs 💙 AKS (CPU limits)
Kubernetes features
- CPU limits
- RAM limits
- Other affiliation
Why?
- Without it one process can starve others
- Some apps are important than others
- Priority can be important
Question: what is the most CPU consuming part of ASP.NET app?
- Start
- Request processing
- GC processing
How?
- Observe
- Observe
- Try
- Fix
- Observe
- Observe
- Try
- Fix
- ....
#7: Functions 💙 AKS (Azure)
How to host Azure Func?
- App Plan - normal
- App Plan - consumption
- App Plan in ASE
Something more?
- Deploy to docker
- Configure storage
- Think about triggers
#7: VNET 💙 AKS (Azure)
VNET
- Configure once - use always
- No way of changing - recreate only
- Same problem with:
- VMSS
- IP Addressees
- Node pool (VM sizes)
Solution
- Full AKS deploy in CI/CD
- Yes full!
- 20 minutes break to recreate everything
- In production create "something" like WAF
#8: NGiNX 💙 AKS (K8s)
Ingress
- K8s "reverse proxy"
- A lot of implementations
- NGiNX most popular
Problems
- Origin host header pass - needs configuration
- Auth cookie size - needs configuration
The end?
Not yet :)
Adv (in Polish)
dotnet <3 Linux & k8s & Azure
By Piotr Stapp
dotnet <3 Linux & k8s & Azure
- 91