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

Feedback on scalability and load testing of a configuration management software

Rudder
February 04, 2020

Feedback on scalability and load testing of a configuration managementย software

๐ŸŽฅ https://www.youtube.com/watch?v=rQlLzVbXEXk
๐Ÿง‘ Nicolas Charles
๐Ÿ“… Configuration Management Camp 2020

RUDDER is based on API/Web application that allows users to configure and verify their configurations. Relying on agents on every system, it checks and remediates configurations every 5 minutes and centralizes the result of application. Each result is made up of hundreds of events that are historized, and each configuration changes involves calculating and displaying the configurations and conformities for users within a reasonable time.

A RUDDER instance can handle 20 000 nodes. Can you imagine what this implies from a network, CPU and storage point of view? How to reach and maintain these performances? What are the different steps that made this possible? And what tools have been put in place?

This presentation will explain the technical stack used (Scala, PostgreSQL, C and Rust), as well as the path, failures and successes that allow us today to reproduce the environments, and also to test and validate the hypotheses to achieve and keep these results.

Rudder

February 04, 2020
Tweet

More Decks by Rudder

Other Decks in Programming

Transcript

  1. rudder.io
    Feedback on scalability and load
    testing of a con๏ฌguration management
    software
    Nicolas CHARLES
    [email protected] - @nico_charles

    View Slide

  2. โ— RUDDER is a Continuous Configuration Management software with a
    Compliance focus
    โ— Configurations are defined with GUI or API
    โ— Configuration checked on every nodes every 5 minutes
    โ— RUDDER computes the compliance of every nodes
    RUDDER - Why scalability is a topic?

    View Slide

  3. RUDDER - De๏ฌning con๏ฌgurations

    View Slide

  4. RUDDER - De๏ฌning con๏ฌgurations
    PARAM
    RULE
    โ—
    Id
    DIRECTIVE
    โ—
    Id
    โ—
    (Components)
    GROUP
    โ—
    Id
    RUDDER con๏ฌg
    (global)
    โ— Policy Mode
    โ— Schedule
    NODE
    โ— Properties
    โ— Policy Mode
    โ— Schedule
    Environmental context
    โ—
    Id : . . .
    โ—
    Generated : . . .
    Files
    Node con๏ฌguration
    Historization
    Historization

    View Slide

  5. RUDDER - Computing compliance
    5
    โ—
    Id : . . .
    โ—
    Generated : . . .
    Files
    Node con๏ฌguration
    RUN
    โ—
    Reports
    โ—
    Reports
    โ—
    ...
    โ—
    ...
    METADATA
    โ—
    node id
    โ—
    con๏ฌg id
    โ—
    run timestamp
    RUN
    โ—
    Reports
    โ—
    Reports
    โ—
    ...
    โ—
    ...
    METADATA
    โ—
    node id
    โ—
    con๏ฌg id
    โ—
    run timestamp
    โ—
    Signature
    Get Policy
    Send con๏ฌguration
    reports
    Expected reports
    (node id, con๏ฌg id,
    timestamp)
    Run reports
    Historization
    Compliance
    (historized)
    Store expected reports
    Metadata
    โ—
    Integrity
    โ—
    Signature
    Con๏ฌg
    โ—
    Id
    โ—
    For Rule R,
    Directive D1,
    Component C
    On every nodes

    View Slide

  6. RUDDER - Compliance

    View Slide

  7. โ— Load testing is the process of putting demand on a system and measuring its
    response.[2]
    โ— Simulating real-world usage, and ensuring the system can sustain it.
    Load testing?
    [2] https://en.wikipedia.org/wiki/Load_testing

    View Slide

  8. โ— For SaaS systems, you manage the lifecycle of your application, so you can
    test for top of next months expected scale.
    โ— For a software deployed on users infrastructures, upgrades are done
    during maintenance windows
    โ—‹ They need (long) migration tests
    โ‡จ You have to think forward
    Testing at what scale??

    View Slide

  9. โ— A German cars manufacturer manages 13 000 nodes with a 3 years-old
    RUDDER 3.1 instance, and 4 500 nodes with a 2 years old RUDDER 4.1
    version
    โ— Need to consolidate on one instance
    โ— Expect 20 000 nodes this year
    How hard can it be?
    RUDDER - Testing at what scale?

    View Slide

  10. โ— RUDDER supports โ€œoldโ€ OS - RHEL 7, SLES 12
    โ— Uses system dependencies, which can be antediluvian: PostgreSQL 9.2,
    rsyslog 8.24.0
    โ—‹ Their performance can be problematic
    RUDDER - Some constraints

    View Slide

  11. RUDDER - architecture
    Rudder Root Server
    Interfaces
    CLI
    WEB UI
    API
    Users
    Applications
    Compliance Con๏ฌguration Inventory
    Rudder Engine + Plugins
    Relay Node
    Rudder Agent
    Node
    Rudder Agent
    Node
    Rudder Agent

    View Slide

  12. RUDDER - components
    Rudder Root Server
    Interfaces
    CLI
    WEB UI
    API
    Users
    Applications
    Compliance Con๏ฌguration Inventory
    Rudder Engine + Plugins
    Relay Node
    Rudder Agent
    Node
    Rudder Agent
    Node
    Rudder Agent
    Scala
    PostgreSQL OpenLDAP
    rsyslog

    View Slide

  13. RUDDER - where could be the bottlenecks?
    Rudder Root Server
    Interfaces
    CLI
    WEB UI
    API
    Users
    Applications
    Compliance Con๏ฌguration Inventory
    Rudder Engine + Plugins
    Relay Node
    Rudder Agent
    Node
    Rudder Agent
    Node
    Rudder Agent

    View Slide

  14. โ— Testing every parts of Rudder
    โ—‹ In isolation first, then all together
    โ—‹ Ramp-up the load
    โ— Inventories
    โ— Set of groups, techniques, directives , rules
    โ— Reports from all nodes
    โ— Relevant logs and way to analyze them
    Testing for 20 000 nodes - what is needed?

    View Slide

  15. โ— Script to generate inventories
    โ—‹ Template + Tsung, contributed by community
    https://github.com/Normation/rudder-tools/tree/master/contrib/stress_suite
    โ—‹ Bash scripts with more flexibility: generated certificates, multiple templates, etc; plus
    persistent data to generate reports
    https://github.com/Normation/rudder-tools/pull/534/files
    Testing for 20 000 nodes - Tooling?

    View Slide

  16. โ— Script to generate reports from created nodes
    โ—‹ Python script to get expected reports from the database, generate and send reports over
    syslog
    https://github.com/Normation/rudder-tools/tree/master/contrib/load-database
    โ—‹ Python script to get expected reports from the database, generates reports, sign them using
    the static data and sends them over HTTPS
    https://github.com/Normation/rudder-tools/pull/534/files
    Testing for 20 000 nodes - Tooling?

    View Slide

  17. โ— First test, with 6000 nodes
    โ— Should be easy, as earlier versions of RUDDER supported 13000 nodesโ€ฆ
    Testing for 20 000 nodes

    View Slide

  18. โ— First test, with 6000 nodes
    โ— Should be easy, as earlier versions of RUDDER supported 13000 nodesโ€ฆ
    โ— Added features in 5.0 have a significant cost in scalability :(
    Testing for 20 000 nodes

    View Slide

  19. โ— The most resource intensive part
    a. Snapshot inventories, groups, directive and rules
    b. Historize data
    c. Convert them in policies mapping
    d. Generate files with data and policies for the nodes
    e. Save expected reports
    f. Run post-generation hooks
    RUDDER - Policy generation

    View Slide

  20. โ— Extract timings
    โ—‹ Each step of Policy Generation is measuredโ€ฆ but
    Done XXX in: 322 350 ms
    is clearly not precise enough
    โ—‹ Need more detailed timings on each parts
    โ–  Aggregate timings over each threads and components
    โ— Process timings
    โ—‹ Automate extracting features from thousands of measures
    โ–  100 000 message โ€œmergeCompareByRules in x msโ€
    RUDDER - Policy generation

    View Slide

  21. โ— Inspect slow parts
    โ—‹ Variable computation
    โ—‹ Database reads/writes
    โ—‹ I/O
    โ— Ensure that memory usage is reasonable
    โ— The core of RUDDER is written in Scala, so there is a lot of available tooling
    RUDDER - Policy generation

    View Slide

  22. โ— jmap (fast)
    โ—‹ histogram of all objects allocated, memory used and number
    โ—‹ dump of JVM state
    RUDDER - JVM tooling

    View Slide

  23. โ— Eclipse Memory Analyzer (async)
    โ—‹ analyse dump and suggest fixes
    โ—‹ doesnโ€™t work great for large heap
    RUDDER - JVM tooling

    View Slide

  24. โ— YourKit
    โ—‹ Instrument the JVM
    โ—‹ Measure object creation, methods calls, memory used, etc
    โ—‹ Great detailed vision
    RUDDER - JVM tooling

    View Slide

  25. โ— YourKit
    โ—‹ Instrument the JVM
    โ—‹ Measure object creation, methods calls, memory used, etc
    โ—‹ Great detailed vision of systems
    โ—‹ But massive slowdown of the application when activated
    RUDDER - JVM tooling

    View Slide

  26. โ— YourKit
    โ—‹ Instrument the JVM
    โ—‹ Measure object creation, methods calls, memory used, etc
    โ—‹ Great detailed vision of systems
    โ—‹ But massive slowdown of the application when activated
    RUDDER - JVM tooling

    View Slide

  27. โ— https://gceasy.io/
    โ—‹ Analyze GC logs and extract metrics and health of GC
    RUDDER - JVM tooling

    View Slide

  28. โ— Facts
    โ—‹ Too many objects are created with super short live
    โ–  Strain on GC, increase CPUs usage
    โ—‹ Some unnecessary computations
    โ—‹ Serializing and deserializing JSON is CPU and Memory expensive
    โ—‹ IO is super expensive
    RUDDER - Policy generation

    View Slide

  29. โ— Optimizations
    โ—‹ Use collection views when necessary
    โ–  Caution, sometimes views are hidden and cause leaks
    โ—‹ Fix some algorithms to remove unnecessary lookups
    โ—‹ Identify the necessary lifespan of big objects, to ensure there are not referenced when not
    necessary
    โ—‹ Batched all requests to database
    โ–  Lower memory usage
    โ–  Big strings from PostgreSQL that are deserialized in one go
    RUDDER - Policy generation

    View Slide

  30. โ— Python script to generate reports
    โ— 3000+ syslog messages/second
    โ— Catastrophic compliance
    RUDDER - Reports and compliance

    View Slide

  31. โ— Python script to generate reports
    โ— 3000+ syslog messages/second
    โ— Catastrophic compliance
    โ— nestat -suna
    โ—‹ 80% of messages are dropped...
    RUDDER - Reports and compliance

    View Slide

  32. โ— rsyslog inserts report in PostgreSQL 1 by 1
    โ—‹ Need to upgrade to 2019 versions
    โ— Increase UDP buffer to handle the load
    โ— Increase the number of workers
    https://docs.rudder.io/reference/5.0/administration/performance.html#_increase_th
    e_udp_buffer
    โ— Fixed the network part for now
    RUDDER - Reports and compliance

    View Slide

  33. โ— rsyslog inserts report in PostgreSQL 1 by 1
    โ—‹ Need to upgrade to 2019 versions
    โ— Increase UDP buffer to handle the load
    โ— Increase the number of workers
    https://docs.rudder.io/reference/5.0/administration/performance.html#_increase_th
    e_udp_buffer
    โ— Fixed the network part for now
    โ—‹ In 6.0, we dropped rsyslog, to use HTTPS reports parsed by a Rust module
    RUDDER - Reports and compliance

    View Slide

  34. โ— Compliance computation canโ€™t deal with all reports
    โ— Process for computation
    โ—‹ Fetch nodes last runs
    โ—‹ Get expected reports
    โ—‹ Get reports from these nodes
    โ—‹ Expand variables, and compute compliance
    โ— Depends on PostgreSQL
    โ— Computations and lookups on the Scala part
    RUDDER - Reports and compliance

    View Slide

  35. โ— PgBadger
    โ—‹ Analyze PostgreSQL logs
    โ—‹ Very complete stats on database usage
    โ–  Top queries, most expensive queries, temp files
    RUDDER - Tooling for PostgreSQL

    View Slide

  36. โ— https://explain.depesz.com/
    โ—‹ Explain query plan
    โ—‹ In an understandable way
    โ—‹ Help correct the queries
    RUDDER - Tooling for PostgreSQL

    View Slide

  37. โ— Give enough resources to PostgreSQL to handle the load
    โ—‹ shared_buffer
    โ—‹ work_mem
    โ—‹ maintenance_work_mem
    โ—‹ temp_buffers
    โ—‹ wal_buffer
    โ— Configure it based on the reality of the system
    โ—‹ random_page_cost is too large for SSD by default
    โ—‹ effective_cache_size
    RUDDER - Con๏ฌgure PostgreSQL

    View Slide

  38. โ— Optimizations in the Scala part
    โ—‹ Improvement in variables detections
    โ—‹ Lighter data structures
    RUDDER - Reports and compliance

    View Slide

  39. โ— Options to disable features to save resources
    โ—‹ Full historization of compliance in database
    โ—‹ Historization of non-compliance reports
    โ—‹ Changes computation
    โ—‹ Recompute of dynamics groups
    RUDDER - Feature ๏ฌ‚ags

    View Slide

  40. โ— Define timeouts, parallelism...
    RUDDER - Tunability

    View Slide

  41. โ— Load testing is time consuming
    โ—‹ 10 minutes to 12 hours for a relevant test
    โ—‹ Enormous logs
    โ–  Scripts to extracts stats on these logs automatically
    โ—‹ Analyzing the results can be tedious
    โ–  Especially as I/O can be erratics (sometimes *4 perf degradation)
    โ— Generating relevant data is hard
    โ—‹ A German cars manufacturer gave us access to a system with their inventories to have real
    data - thank you !
    RUDDER - Load Testing Takeaway

    View Slide

  42. โ— Beware of intuitions
    โ—‹ Guesses and hypothesis are often wrong
    โ–  Need to be meticulous
    โ—‹ Some code or may look bad, but turn out to be pretty efficient
    โ— You need to be persistent
    โ—‹ Only after looking many times at the same code did I see potential issues.
    โ—‹ Some changes needed a lot of thinking and interaction with other developers
    โ–  Thank you for bearing with me!!
    RUDDER - Load Testing Takeaway

    View Slide

  43. โ— Sometimes, making things faster makes them slower
    โ—‹ As they starve other resources
    โ—‹ Policy generation suffered from improved compliance computation
    โ— Libraries/dependencies have a real impact on performance
    โ—‹ Our JSON serializing/deserializing library is 8 years old, and really inefficient
    โ—‹ Templating engine library is not thread-safe
    โ—‹ Upgrading rsyslog, postgresql and java helped a lot
    RUDDER - Load Testing Takeaway

    View Slide

  44. โ— JVM JIT optimizes a lot of stuff
    โ—‹ Some optimizations failed to change anything
    โ—‹ JIT optimized the hell out of it
    โ—‹ Unit tests show massive perf improvement over each execution iteration
    RUDDER - Load Testing Takeaway

    View Slide

  45. โ— Some changes are simply too large for a minor version
    โ—‹ Next optimization can only fit in a major version:
    โ–  stream from/to database
    โ–  rewrite algorithms
    โ–  change serialization/deserialization librairies
    โ–  change templating engine
    โ–  generate policies node by node
    RUDDER - Load Testing Takeaway

    View Slide

  46. โ— Improving scalability in one point shows the next bottlenecks
    โ—‹ It can feel like a never ending task
    โ—‹ But they get smaller and smaller
    RUDDER - Load Testing Takeaway

    View Slide

  47. โ— Results
    โ—‹ 28 PRs for performance in 3 latests minors versions of Rudder
    โ—‹ 30% improvement in memory usage
    โ—‹ 40% faster compliance computation
    RUDDER - Did it matter?

    View Slide

  48. โ— Policy generation time is linear in number of nodes and components
    โ— Memory usage is linear-ish in number of nodes and components
    โ— With complex configuration (JS variables, many components per nodes):
    โ—‹ 4500 nodes, 1,6 Million components: 10 GB, 13 minutes for policy generation
    โ—‹ 10 000 nodes, 11 Millions components: 67 GB, 40 minutes
    โ—‹ 12 000 nodes, 13,2 Millions components: 82 GB, 48 minutes
    โ— With actual german manufacturer configuration
    โ—‹ Full policy generation for 12 500 nodes in 7m40
    RUDDER - Did it matter?

    View Slide

  49. โ— RUDDER is limited by available IO and Memory
    โ—‹ It does make really good use of CPUs
    โ— With enough RAM, RUDDER supports 20k nodes
    RUDDER - Did it matter?

    View Slide

  50. โ— Test on platform with 1TB RAMDisk
    โ—‹ Lower cost of I/O
    โ— Automate all these tests and measures
    โ—‹ System is now stable enough to be automated
    RUDDER - Whatโ€™s next?

    View Slide

  51. โ— Repeat on branch 6.0
    โ—‹ Totally different underlying framework
    โ—‹ Code changed a lot between the two branches
    โ—‹ Many new features in 6.0
    โ—‹ A lot of work has already been done, but we hope to have better perfs than in 5.0
    RUDDER - Whatโ€™s next?

    View Slide

  52. โ— Build with observability
    โ—‹ Gather data, measure evolution
    โ—‹ Donโ€™t need to add logs when an issue arise
    โ—‹ Helpful to identify performance regression
    โ—‹
    โ— Keep the librairies up to date
    โ—‹ Evaluate new librairies regularly
    โ—‹ Enormous cost of changing deprecated librairies
    โ—‹ Huge impact in performance and quality
    What could have been better?

    View Slide

  53. rudder.io
    Feedback on scalability and load testing of a con๏ฌguration
    management software
    Questions ?

    View Slide

  54. โ— Why not testing with real 20000 nodes?
    โ—‹ Mimicking the nodes give pertinent insights
    โ—‹ Itโ€™s cost effective (the test platform cost ~100โ‚ฌ/month)
    โ—‹ Setting up an infra (storage, network, etc) for 20000 nodes is *really* complex and time
    consuming
    โ–  Even in the cloud
    โ–  And it needs to run for quite a long time
    The elephant in the room

    View Slide

  55. โ— Why not Gatling???
    โ—‹ A lot of iterations and tests of tests
    โ—‹ Tests on several versions with different methods
    โ—‹ Need to consolidate
    The elephant in the room

    View Slide