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

How to spot bottleneck in web applications

How to spot bottleneck in web applications

K.Skaradziński

May 22, 2017
Tweet

More Decks by K.Skaradziński

Other Decks in Programming

Transcript

  1. Greenfield Development happens when you start a brand new project,

    as in, clean slate development. No legacy code lying around, no old development to maintain. You’re starting afresh, from scratch, from a blank slate, with no restrictions on what you’re doing (other than business rules of course).
  2. Brownfield Development happens when business decide to develop/improve upon an

    existing application infrastructure. As an upgrade is implemented into an existing solution, the development is said to be Brownfield.
  3. The Wall Clock Time, or Wall Time, for a function

    call is the measure of the real time it took for PHP to execute its code: the difference between the time at which PHP entered the function and the time at which PHP left the function
  4. The CPU time is the amount of time the CPU

    was used for processing instructions.
  5. The I/O time is the time the CPU waited for

    input/output (I/O) operations.
  6. Network activity includes calls to databases like MySQL, PostgreSQL, or

    MongoDB; HTTP calls to web services and APIs; calls to cache systems like Redis and Memcached; communications with services like queues, email daemons, remote filesystems; etc.
  7. Disk activity occurs when a program reads files from the

    filesystem, including when PHP loads a script or class file.
  8. Wall Time = CPU Time + I/O Time I/O Time

    = Network Time + Disk Time
  9. blackfire --samples=1 --new-reference curl http://www.goldenline.pl/ Blackfire cURL completed Graph URL

    https://blackfire.io/profiles/4cf06d0d-afab-484c-ba7a-c7377f7c4e48/graph Reference: #1. Untitled Wall Time 233ms CPU Time 228ms I/O Time 4.75ms Memory 43.4MB Network n/a SQL n/a
  10. blackfire --samples=1 --reference=1 curl http://www.goldenline.pl/ Blackfire cURL completed Graph URL

    https://blackfire.io/profiles/compare/4cf06d0d-afab-484c-ba7a-c7377f7c4e48...5e719 fd0-5839-4495-866a-142181a0f4a1/graph Wall Time 207ms -26ms -14.5% CPU Time 176ms -52ms -14.5% I/O Time 30.6ms +25.9ms +45.8% Memory 43.4MB +8.88KB n/s Network 13µs 294B 1rq SQL n/a -
  11. blackfire --samples=1 --reference=1 curl http://www.goldenline.pl/ Blackfire cURL completed Graph URL

    https://blackfire.io/profiles/compare/4cf06d0d-afab-484c-ba7a-c7377f7c4e48...5e719 fd0-5839-4495-866a-142181a0f4a1/graph 1 recommendation https://blackfire.io/profiles/5e719fd0-5839-4495-866a-142181a0f4a1/graph?settin gs%5BtabPane%5D=recommendations Wall Time 207ms -26ms -14.5% CPU Time 176ms -52ms -14.5% ...
  12. .blackfire.yml tests: "Home Page": path: "/" assertions: - metrics.redis.connections.count ==

    1 - metrics.amqp.connections.count == 0 - main.memory < 40Mb
  13. Writing assertions on the main profile costs is as easy

    as adding a valid dimension name to the main. Prefix: • count • wall_time • cpu_time • memory • peak_memory • io • network_in • network_out
  14. .blackfire.yml scenarios: Pricing page: - /pricing Integrations page: - /integrations

    Blackfire.yml Validator: - path: /docs/validator method: POST samples: 10
  15. # Time: 100224 19:50:45 # User@Host: root[root] @ localhost [127.0.0.1]

    # Query_time: 89.843750 Lock_time: 0.000000 Rows_sent: 6256088 Rows_examined: 3 use we; SET timestamp=1267037445; select * from places,employees,departments,votes;
  16. {{ app.user }} {{ app.request.query.get('page') }} vs {% set user

    = app.user %} {% set page = app.request.query.get('page') %}
  17. <div class="project-list"> {% for project in projects %} <p>{{ project.name

    }}</p> {% if is_granted('SUPER_ADMIN') %} <a href="{{ path('project', { 'id': project.id }) }}" class="btn btn-lg btn-primary btn-huge">{{ 'remove' | trans({}, 'top') }}</a> {% endif %} {% endfor %} </div>
  18. <div class="project-list"> {% for project in projects %} <p>{{ project.name

    }}</p> {% if is_granted('SUPER_ADMIN') %} <a href="{{ path('project', { 'id': project.id }) }}" class="btn btn-lg btn-primary btn-huge">{{ 'remove' | trans({}, 'top') }}</a> {% endif %} {% endfor %} </div>