O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Three Lessons about Gatling and Microservices

2.185 visualizações

Publicada em

Gatling, one of the most popular stress test OSS frameworks, is powered by Akka and Scala. In this talk I share insight gained while working with and customizing Gatling to exercise Protobuf-based backed services. I also show how to use Gatling for web applications.

Publicada em: Tecnologia
  • Seja o primeiro a comentar

Three Lessons about Gatling and Microservices

  1. 1. Three Lessons about Gatling & Microservices Dragos Manolescu  Maps Evaluation Tools December 8, 2015
  2. 2. Dragos Manolescu • Sr. software engineer @ Apple • Formerly @ Whitepages, HP, … • Scala user since ≈ 2010 • Seattle Scala Meetup speaker
  3. 3. Gatling • gatling.io • OSS (Apache 2.0) stress-test framework • Scala, Akka and Netty • Demos and code with version 2.1.7 • Download choices: • bundle → end users • libraries → developers
  4. 4. Context: Web Applications Web Application name Jim Clark city Mountain View state CA Form
  5. 5. Demo: Gatling Recorder
  6. 6. Demo Summary • Capture HTTP traffic via proxy • Generate Scala code • Run gatling: • Compile and execute generated code • Generate reports
  7. 7. Gatling Domain Model Stress Testing Web App Testing Service Testing Real-time Reporting Gatling Simulation Service 1 Service N Web Application - Static content (media, CSS, etc.) - Dynamic content Code (Scala simulation DSL) Netty (non- blocking, asynchronous network I/O) Feeders Writers Console File Graphite Checks Assertions Request/Response Transformations Configuration <<sends results to>> <<reads data from>> <<reads params from>> <<compiles and executes>> Recording Proxy <<generates>> Browser
  8. 8. 1: Configuration
  9. 9. Java/NIO Warmup
  10. 10. Startup Debugging 14:31:59.300 [INFO ] i.g.h.a.HttpEngine - Start warm up 14:31:59.341 [DEBUG] i.n.u.i.ThreadLocalRandom - -Dio.netty.initialSeedUniquifier: 0x79b5d831f7fc3c94 (took 0 ms) 14:31:59.368 [DEBUG] i.n.b.ByteBufUtil - -Dio.netty.allocator.type: unpooled 14:31:59.368 [DEBUG] i.n.b.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 65536 14:31:59.401 [DEBUG] i.n.u.i.JavassistTypeParameterMatcherGenerator - Generated: io.netty.util.internal.__matchers__.io.netty.handler.codec.http.HttpObjectMatcher ..(waiting for timeout) .. 14:32:59.207 [DEBUG] o.a.n.c.p.DefaultChannelPool - Closed 0 connections out of 0 in 0ms 14:32:59.411 [DEBUG] o.a.n.c.NettyConnectListener - Trying to recover from failing to connect channel [id: 0x80a1e121] with a retry value of true 14:32:59.413 [DEBUG] o.a.n.c.NettyConnectListener - Failed to recover from connect exception: io.netty.channel.ConnectTimeoutException: connection timed out: foo.apple.com/10.0.1.212:80 with channel [id: 0x80a1e121]
  11. 11. Startup Debugging (2) strace -q -f -e trace=network bin/gatling.sh -sf ~/simulations ... [pid 24981] connect(74, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("216.58.192.40")}, 16) = -1 ETIMEDOUT (Connection timed out) [pid 24981] socketpair(PF_FILE, SOCK_STREAM, 0, [79, 80]) = 0
  12. 12. gatling-defaults.conf
  13. 13. 2: Simulations
  14. 14. Gatling Simulation
  15. 15. Injecting Virtual Users
  16. 16. Injections, Visualized (1) constantUsersPerSec(100) during(90 seconds) randomized 0 2500 5000 7500 10000 1449080844 1449080860 1449080876 1449080892 1449080908 1449080924 count 0 22.5 45 67.5 90 14490808441449080859 14490808741449080889 14490809041449080919 1449080934 mean_rate m1_rate
  17. 17. Injections, Visualized (2) rampUsersPerSec(10) to (100) during(90 seconds) 0 1250 2500 3750 5000 1449081183 1449081198 1449081213 14490812281449081243 14490812581449081273 count 0 15 30 45 60 1449081183 1449081197 14490812111449081225144908123914490812531449081267 mean_rate m1_rate
  18. 18. Injections, Visualized (3) heavisideUsers(100) over(90.seconds) 0 25 50 75 100 1449082217 1449082231 1449082245 1449082259 1449082273 1449082287 1449082301 count 0 0.35 0.7 1.05 1.4 1449082217 1449082232 1449082247 1449082262 1449082277 1449082292 mean_rate m1_rate
  19. 19. Injections, Visualized (4) splitUsers(100) into(rampUsers(20) over(10.seconds)) separatedBy(10.seconds) 0 25 50 75 100 1449082976 144908299014490830041449083018 144908303214490830461449083060 count 0 0.3 0.6 0.9 1.2 14490829761449082990 144908300414490830181449083032 14490830461449083060 mean_rate m1_rate
  20. 20. Gatling Feeders • Populate user sessions w/ data • External sources: • CSV file (reads all in memory) • JSON • JDBC • Redis
  21. 21. CSV or Redis? 0 0.175 0.35 0.525 0.7 14489275911448927602 1448927613144892762514489276361448927647 Heap usage 0 0.175 0.35 0.525 0.7 1448928776144892878314489287901448928797144892880514489288121448928819 Heap usage
  22. 22. Protobuf Requests
  23. 23. Protobuf Responses and Checks
  24. 24. 3. Dev tool
  25. 25. Demo: sbt-gatling plugin
  26. 26. Demo Summary • Gatling simulation part of the source tree • sbt-revolver: start project in a forked JVM • gatling-sbt: runs simulations
  27. 27. Wrapping Up • Gatling for web applications, microservices • Understand simulation & engine configuration • Map to service protocol • Dev tool for testing services within sbt
  28. 28. Thank you!

×