Choose the right technology to
build your micro-service
Programming Language
Agenda
• The history of programming Language
• DotNet core JIT & AOT
• Python the swiss knife
• Golang the newborn in the family
• Solving Fibonacci challenge
• Comparing performance
• Conclusion
https://github.com/CloudReady-club/fibonacci
Compiled to machine code Interpreted language Two-steps compilation
1970
1990
2010
C
C++
Objective-C
Perl
Python
VB Ruby
JAVA
PHP
JavaScript
.Net
Go
Rust
High Level programming languages timeline
.Net
Core
DotNet Core SDK
DotNet runtime
Start application using dotnet
command
Just in time complication
Publish with target OS configuration
Native Code Native Code Native Code
DotNet Core SDK
Execution
Operating System
Native code
Needs some libraries installed
Ahead of time complication
C#
Compiler
F#
Compiler
Visual Basic
Compiler
JScript
Compiler
Go Used by
Kubernetes
• Designed at Google in 2007
• Version 1.0 releases in March 2012
• Post-OOP programming language
• C language family
• C++ like performance
• Safe memory management
• Cross platform compiling to native code
• Used only for Backend development
• Support concurrency pattern : Go routine
Go compiler with target OS
Native Code Native Code Native Code
Go SDK
Execution
Operating System
Native code
Ahead of time complication
Golang
Source code
Fibonacci challenge
await Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(config => {
config
.ConfigureKestrel(options => {
options.Listen(IPAddress.Any, 8082, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http1AndHttp2;
});
})
.Configure(app => {
app.UseRouting()
.UseEndpoints(endpoint => {
endpoint.MapGet("/fibonacci" ,GetFibonacci);
endpoint.MapGet("/healthz", GetHealthz);
});
});
})
.Build()
.RunAsync();
Start Web Server DotNet
Start Web Server Golang
func main() {
http.HandleFunc("/fibonacci", getFibonacci)
http.HandleFunc("/healthz", getHealthzt)
err := http.ListenAndServe(":8080", nil)
if err != nil {
log.Fatal(err)
}
}
Start Web Server Python
from flask import Flask
app = Flask(__name__)
if __name__ == "__main__":
from waitress import serve
serve(app, host="0.0.0.0", port=8080)
private BigInteger Fibonacci(){
var a = new BigInteger(0);
var b = new BigInteger(1);
BigInteger tmp;
var limit = BigInteger.Pow(10,9999);
while(BigInteger.Compare(a,limit) < 0)
{
a = BigInteger.Add(a,b);
tmp = a;
a = b;
b = tmp;
}
return a;
}
func fibonacci() *big.Int {
a := big.NewInt(0)
b := big.NewInt(1)
var limit big.Int
limit.Exp(big.NewInt(10),
big.NewInt(9999), nil)
for a.Cmp(&limit) < 0 {
a.Add(a, b)
a, b = b, a
}
return a
}
fibonacci.cs
Fibonacci Algorithm
def getFibonacci():
a = 0
b = 1
limit = 10 ** 9999
while a < limit:
a = a + b
a,b = b,a
return a
fibonacci.go
fibonacci.py
Performance
C# with JIT compilation C# with AOT Compilation Python Go
Total lines of code 66 lines 66 lines 35 lines 58 lignes
Binary Package size
after build
1.1 MB 38 Mo N/A 4.6 MB
Docker base image mcr.microsoft.com/dotnet/aspnet:6.0 amd64/alpine:3.14 python:3.8-alpine gcr.io/distroless/base-
debian11
Docker image size 209 MB 48 MB 58 MB 24 MB
AVG Response time
(load test 10 users X
10 requests)
3077 ms 2562 ms 1440 ms 731 ms
Memory footprint 22 Mi 16Mi 18Mi 2 Mi
Stress test 50 users
during 10 mn
98% Errors 10% Errors 0% errors 0% Errors
Performance
Performance
• Go and python services scale up to 8 replicas
• Dotnet services scale up to 5 replicas
• Go and Python services scale before dotnet services
• Go scales down just after the end of stress test
• Python service takes more time to scale down due
to CPU usage after the end of the test
• Dotnet services need more time to scale up => need
more time to start new instance
Golang Python Dotnet Core
• Performance
• Memory usage
• Service start time
• Learning curb
• New programming language
• Maturity of the language
• Mature programming language
• Simplicity of the code
• Availability of different packages
• The most used programming
language
• Micro-services application
• Application for the cloud
• Interpreted language
• Memory efficiency
• Data Science, AI,bigData
• Mature programming Platform
• General propose Platform
• Support of Microsoft
• Implement JIT & AOT compilation
• Performance and memory
efficiency
• Service start time
• Monolith application
• UI application
Multi-platform
Pros
Cons
Used for
Conclusion
https://github.com/CloudReady-club/fibonacci https://cloudready.club

Micro servoces-choose-the-right-tools-programing-language

  • 1.
    Choose the righttechnology to build your micro-service Programming Language
  • 2.
    Agenda • The historyof programming Language • DotNet core JIT & AOT • Python the swiss knife • Golang the newborn in the family • Solving Fibonacci challenge • Comparing performance • Conclusion https://github.com/CloudReady-club/fibonacci
  • 3.
    Compiled to machinecode Interpreted language Two-steps compilation 1970 1990 2010 C C++ Objective-C Perl Python VB Ruby JAVA PHP JavaScript .Net Go Rust High Level programming languages timeline .Net Core
  • 6.
    DotNet Core SDK DotNetruntime Start application using dotnet command Just in time complication
  • 7.
    Publish with targetOS configuration Native Code Native Code Native Code DotNet Core SDK Execution Operating System Native code Needs some libraries installed Ahead of time complication C# Compiler F# Compiler Visual Basic Compiler JScript Compiler
  • 9.
    Go Used by Kubernetes •Designed at Google in 2007 • Version 1.0 releases in March 2012 • Post-OOP programming language • C language family • C++ like performance • Safe memory management • Cross platform compiling to native code • Used only for Backend development • Support concurrency pattern : Go routine
  • 10.
    Go compiler withtarget OS Native Code Native Code Native Code Go SDK Execution Operating System Native code Ahead of time complication Golang Source code
  • 11.
  • 12.
    await Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(config =>{ config .ConfigureKestrel(options => { options.Listen(IPAddress.Any, 8082, listenOptions => { listenOptions.Protocols = HttpProtocols.Http1AndHttp2; }); }) .Configure(app => { app.UseRouting() .UseEndpoints(endpoint => { endpoint.MapGet("/fibonacci" ,GetFibonacci); endpoint.MapGet("/healthz", GetHealthz); }); }); }) .Build() .RunAsync(); Start Web Server DotNet
  • 13.
    Start Web ServerGolang func main() { http.HandleFunc("/fibonacci", getFibonacci) http.HandleFunc("/healthz", getHealthzt) err := http.ListenAndServe(":8080", nil) if err != nil { log.Fatal(err) } }
  • 14.
    Start Web ServerPython from flask import Flask app = Flask(__name__) if __name__ == "__main__": from waitress import serve serve(app, host="0.0.0.0", port=8080)
  • 15.
    private BigInteger Fibonacci(){ vara = new BigInteger(0); var b = new BigInteger(1); BigInteger tmp; var limit = BigInteger.Pow(10,9999); while(BigInteger.Compare(a,limit) < 0) { a = BigInteger.Add(a,b); tmp = a; a = b; b = tmp; } return a; } func fibonacci() *big.Int { a := big.NewInt(0) b := big.NewInt(1) var limit big.Int limit.Exp(big.NewInt(10), big.NewInt(9999), nil) for a.Cmp(&limit) < 0 { a.Add(a, b) a, b = b, a } return a } fibonacci.cs Fibonacci Algorithm def getFibonacci(): a = 0 b = 1 limit = 10 ** 9999 while a < limit: a = a + b a,b = b,a return a fibonacci.go fibonacci.py
  • 16.
    Performance C# with JITcompilation C# with AOT Compilation Python Go Total lines of code 66 lines 66 lines 35 lines 58 lignes Binary Package size after build 1.1 MB 38 Mo N/A 4.6 MB Docker base image mcr.microsoft.com/dotnet/aspnet:6.0 amd64/alpine:3.14 python:3.8-alpine gcr.io/distroless/base- debian11 Docker image size 209 MB 48 MB 58 MB 24 MB AVG Response time (load test 10 users X 10 requests) 3077 ms 2562 ms 1440 ms 731 ms Memory footprint 22 Mi 16Mi 18Mi 2 Mi Stress test 50 users during 10 mn 98% Errors 10% Errors 0% errors 0% Errors
  • 17.
  • 18.
    Performance • Go andpython services scale up to 8 replicas • Dotnet services scale up to 5 replicas • Go and Python services scale before dotnet services • Go scales down just after the end of stress test • Python service takes more time to scale down due to CPU usage after the end of the test • Dotnet services need more time to scale up => need more time to start new instance
  • 20.
    Golang Python DotnetCore • Performance • Memory usage • Service start time • Learning curb • New programming language • Maturity of the language • Mature programming language • Simplicity of the code • Availability of different packages • The most used programming language • Micro-services application • Application for the cloud • Interpreted language • Memory efficiency • Data Science, AI,bigData • Mature programming Platform • General propose Platform • Support of Microsoft • Implement JIT & AOT compilation • Performance and memory efficiency • Service start time • Monolith application • UI application Multi-platform Pros Cons Used for Conclusion
  • 21.