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

PyConIT: Monitora le performance della tua applicazione Python Flask con Elasticsearch e Kibana

PyConIT: Monitora le performance della tua applicazione Python Flask con Elasticsearch e Kibana

Matteo Zuccon

April 20, 2018
Tweet

More Decks by Matteo Zuccon

Other Decks in Programming

Transcript

  1. Agenda • What is performance? Definition and meaning • APM

    - Application Performance Management • Open Source APM with and • Monitor Flask Application
  2. What is performance? “total effectiveness of an application or computer

    system, including throughput , individual response time, and availability” Something is successful in producing a desired result; success
  3. What is performance? Monitoring • Application Avg Response Time •

    Application Load • Monitoring CPU of servers • Tracking and log errors • Everything useful for you – depending from your use case and application
  4. APM - Application Performance Management “In the fields of information

    technology and systems management, application performance management (APM) is the monitoring and management of performance and availability of software applications.” “the translation of IT metrics into business meaning”
  5. APM - Management and Monitoring being more proactive only being

    reactive when it comes to the performance Application performance management or application performance monitoring.
  6. APM – Components – 1 of 2 • Performance of

    individual web requests or transactions • Usage and performance of all application dependencies like databases, web services, caching, etc • Detailed transaction traces down to specific lines of code • Code level performance profiling • Basic server metrics like CPU, memory, etc
  7. APM – Components – 2 of 2 • Evaluate performance

    management criteria • Application aware and focused – understand application context • Custom applications metrics created by the dev team or business • Application log data and errors • Real time monitoring
  8. APM – Tools • New Relic • Glimpse • Miniprofiler

    • XRebel • Stackify Prefix • App Dynamics • Scout Devtrace • Rack trace • Zend Z-Ray
  9. APM – Not that easy- Where do I start? A

    lot of components, tools, books, practices….
  10. Elasticsearch and Kibana Elasticsearch is a distributed, RESTful search and

    analytics engine, heart of the Elastic Stack, it centrally stores your data. Kibana lets you visualize your Elasticsearch data and navigate the Elastic Stack
  11. Open Source APM - Elastic Already housing logs and system

    metrics in Elasticsearch? Expand to application metrics with Elastic APM. Four lines of code lets you see a bigger picture to quickly fix issues and feel good about the code you push. (basic subscription – Free license) Elasticsearch and doubling down on “open”: https://changelog.com/podcast/292
  12. APM – Components - Elasticsearch •Elasticsearch • APM Server •

    APM Agents • Kibana APM UI Centrally stores the application metrics
  13. APM – Components – APM Server • Elasticsearch •APM Server

    • APM Agents • Kibana APM UI Open source application written in Go which runs on your servers. It receives data from agents periodically. The API is a simple JSON based HTTP API. APM Server builds Elasticsearch documents from the data received from agents.
  14. APM – Components – APM Agents • Elasticsearch • APM

    Server •APM Agents • Kibana APM UI Hook into your application and start collecting performance metrics and errors automatically. Collected data is buffered for a short period and sent on to APM Server.
  15. APM – Components - Kibana • Elasticsearch • APM Server

    • APM Agents •Kibana APM UI dashboard to visualize the APM metrics
  16. APM - Agents • Python* • NodeJS • Ruby •

    Java • Go • JavaScript Version 1.8 – 2.0 Version 0.10+ * no support async frameworks like Twisted or Tornado
  17. Elastic APM - Pros • Open Source, free and easy

    to use • APM Agents • Fully integrated with Elasticsearch • Built in Kibana Dashboard
  18. APM – Python Flask - Configuration pip install elastic-apm[flask] For

    apm-server 6.2+, make sure you use version 2.0 or higher of elastic-apm
  19. APM – Python Flask - Routes Automatically track transactions and

    capture uncaught exceptions within Flask.
  20. APM – Python Flask – Arbitrary Exception Send additional events

    by raising an exception or logging a generic message
  21. APM –Tuning and Overhead considerations • CPU time • Memory

    • Bandwidth use • Elasticsearch storage • Transaction Sample Rate: randomly sample only a subset of transactions • Transaction Queue: reduce queue size and flush time • Spans per transaction: transactions should have well below 100 spans
  22. APM – Elastic - Python • Agents ready to go

    (Flask and Django) • Few lines of code • Custom exceptions and messages • Transactions and requests • Exclude route and sanitize data • APM Server public API
  23. APM – Elastic - Python Thank you Questions? @matteo_zuccon [email protected]

    https://whiletrue.run #PyconNove #PyconIT @pyconit https://bit.ly/2JYGZtZ