Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swifty microservices in production

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for Marcin Kliks Marcin Kliks
September 18, 2018

Swifty microservices in production

Avatar for Marcin Kliks

Marcin Kliks

September 18, 2018

More Decks by Marcin Kliks

Other Decks in Technology

Transcript

  1. About • Marcin Kliks • Devops Teams Lead @ Allegro

    • Ralph CMDB http://github.com/allegro/ ralph • Loves clean & performant code
  2. Smaller images • WebP? • PNG and JPEG - most

    compatible ones • Performant solution for thousands of images
  3. C library integration • How easy is it to integrate

    and to compile? • How can you debug it? • What’s the performance / latency cost? • How do you release it? • Types conversion?
  4. C library integration Single compiler Debugging Perf. Penalty Types briding

    Golang ✅ (CGo) No 5x ❌ Java ❌ No 10 - 25x ❌ Python ❌ No Significant ❌ Swift ✅ Yes, Xcode Zero, native calls ✅
  5. C library integration Single compiler Debugging Perf. Penalty Types briding

    Golang ✅ (CGo) No 5x ❌ Java ❌ No 10 - 25x ❌ Python ❌ No Significant ❌ Swift ✅ Yes, Xcode Zero, native calls ✅
  6. Performance • 3x lower memory usage than Java • Value

    types! • No Garbage collector! • Predictive performance
  7. Used components • Swift 4.1 • SPM • Vapor 2

    (porting to 3) • GCD • HTTPS / TCP Client
  8. Preparations • Choosing Server Side Swift framework • Prepare runtime

    environment on Mesos • In-house Docker images for Swift • Plug into ecosystem • CI • One click deployment • Security checks • Compliance checks • Autodiscovery, logs, metrics … • Implement Microservice Contract
  9. Implementing microservice with Swift • Helper library („swidamio”) • Configuration

    Service Client • Graphite client • Logging client • Microservice Contract
  10. System or vendoring? • Linking to system libraries (installed with

    homebrew, apt) • Faster compiles • Package manager responsible for updates • Sources included(„vendored”) within the app • Customizable • Longer compiles
  11. Challenges • Catching fatal errors in production / Sentry •

    All functions throwable • Memory profiling in production • C-based profilers?
  12. 2 * 100 instances in 40 seconds
 - including health

    checks
 - nothing preinstalled on clusters
  13. What’s next? • We just got started (PNG, one Showcase

    Area) • Next step: compress more areas with PNG + JPG
  14. Good parts • FAST, predictive performance, and fast to scale

    • Amazing c-libraries integration • Powerful language with safe code constructs
  15. Missing parts… • Framework agnostic libraries like Logging, Metrics •

    Boundles • Stacktraces for fatal C / Unwrap crashes • Memory profiling on Linux • Better tooling
  16. The best for • Performance-oriented microservices • Safer C libraries

    wrappers • ML / CPython integration (Dynamic Callable) • …