pinba in-memory mysql storage engine for a full-stack real ... · pinba in-memory mysql storage...

30
Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Upload: others

Post on 12-Sep-2019

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Pinbain-memory MySQL storage engine for a

full-stack real-time performance analytics

Antony DovgalAlexey Rybak

Page 2: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Once upon a time... ...there was a dating site which didn’t have any of these:

● Monitoring● QA● Fridge● Fancy office

Page 3: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Once upon a time... This is what was used for monitoring:

Yes, it’s an MRTG traffic graph

Page 4: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

The Problem✦ How many requests per second are served?

✦ How slow are they?

✦ What are the slowest scripts?

✦ What makes them slow?

✦ How servers perform?

✦ Where’s the fridge?

Page 5: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Yet another acronymP – PHP

I – is

N – not a

B – bottleneck

A – anymore

Page 6: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

What is it?✦ It’s a daemon

✦ It’s a MySQL storage engine

✦ Which doesn’t really store anything

✦ At least not for long

Page 7: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

What does it do?✦ Receives Protobuf packets by UDP from servers✦ Aggregates data in multiple ways✦ Provides SQL interface via MySQL

MySQL [pinba]> select req_count/time_interval as req_per_sec from info;

+-------------+

| req_per_sec |

+-------------+

| 66577.2100 |

+-------------+

1 row in set (0.04 sec)

Page 8: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Sliding Window✦ We don’t have infinite RAM (yet)

✦ So we store the data for N seconds

✦ Incoming raw data is processed on the fly

✦ Raw data older than N seconds is thrown away

Page 9: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Sliding WindowData

Page 10: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Raw Data✦ Request duration

✦ Server hostname

✦ Domain name

✦ Script name

✦ Bytes sent

✦ Rusage

✦ Timers

✦ Some more

Page 11: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Timers

✦ A way to measure certain parts of application

✦ Timer properties:

Time

CPU time

Tags: group=mysql, operation=insert, result=ok

Page 12: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Timers

Pseudo-code example:T = timer_start([group=mysql, op=insert, server=dbs10])

R = mysql_insert(“INSERT INTO..”)

timer_stop(T)

timer_add_tag(T, [result = (R ? ‘ok’ : ‘error’)])

Page 13: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Aggregated Data

✦ Basic reports

✦ Timer reports

✦ Request tag reports

Page 14: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Basic Reports

✦ info - the most basic of all

✦ report aggregated by script

✦ report aggregated by domain

✦ report aggregated by hostname

✦ and variations of all of the above

Page 15: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Creating a ReportCREATE TABLE `info` (

`req_count` int(11) DEFAULT NULL,

`time_total` float DEFAULT NULL,

`ru_utime_total` float DEFAULT NULL,

`ru_stime_total` float DEFAULT NULL,

`time_interval` int(11) DEFAULT NULL,

`kbytes_total` float DEFAULT NULL,

`memory_footprint` float DEFAULT NULL,

`req_time_median` float DEFAULT NULL

) ENGINE=PINBA COMMENT='info';

Page 16: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Example: infoMySQL [pinba]> select req_count, time_interval, req_time_median from info;

+-----------+---------------+-----------------+

| req_count | time_interval | req_time_median |

+-----------+---------------+-----------------+

| 137911 | 100 | 0.0179072 |

+-----------+---------------+-----------------+

1 row in set (0.04 sec)

MySQL [pinba]> select req_count/time_interval from info;

+-------------------------+

| req_count/time_interval |

+-------------------------+

| 1389.9600 |

+-------------------------+

1 row in set (0.05 sec)

Page 17: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Example: report by scriptCREATE TABLE `report_by_script_name` (

`req_count` int(11) DEFAULT NULL,

`req_per_sec` float DEFAULT NULL,

`req_time_total` float DEFAULT NULL,

`req_time_percent` float DEFAULT NULL,

`req_time_per_sec` float DEFAULT NULL,

`ru_utime_total` float DEFAULT NULL,

`ru_utime_percent` float DEFAULT NULL,

`ru_utime_per_sec` float DEFAULT NULL,

`ru_stime_total` float DEFAULT NULL,

`ru_stime_percent` float DEFAULT NULL,

`ru_stime_per_sec` float DEFAULT NULL,

`traffic_total` float DEFAULT NULL,

`traffic_percent` float DEFAULT NULL,

`traffic_per_sec` float DEFAULT NULL,

`script_name` varchar(128) DEFAULT NULL,

`memory_footprint_total` float DEFAULT NULL,

`memory_footprint_percent` float DEFAULT NULL,

`req_time_median` float DEFAULT NULL,

`index_value` varchar(256) DEFAULT NULL

) ENGINE=PINBA COMMENT='report1'

Page 18: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Example: report by scriptMySQL [pinba]> select req_count, req_per_sec, script_name, req_time_median from

report_by_script_name order by req_per_sec desc limit 5;

+-----------+-------------+---------------------------------------+-----------------+

| req_count | req_per_sec | script_name | req_time_median |

+-----------+-------------+---------------------------------------+-----------------+

| 91179 | 911.79 | /comet/init.phtml | 0.0166647 |

| 7432 | 74.32 | Web\WebAppFrame::index | 0.0855364 |

| 5603 | 56.03 | /profile.phtml | 0.0182654 |

| 2994 | 29.94 | Web\Web_Profile::actionNonAuthorized | 0.143617 |

| 2353 | 23.53 | Web\Web_BigPhoto::actionNonAuthorized | 0.068779 |

+-----------+-------------+---------------------------------------+-----------------+

Page 19: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Timer/tag reports

✦ aggregated by tag values (1/2/N tags)

✦ aggregated by script and tag values

✦ aggregated by script, hostname,

domain name and tag values

Page 20: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Timer/tag reportsMySQL [pinba]> select tag_value, hit_count, timer_value/hit_count

from tag_info_group order by timer_value desc limit 5;

+------------------------+-----------+-----------------------+

| tag_value | hit_count | timer_value/hit_count |

+------------------------+-----------+-----------------------+

| db::select | 71480 | 0.010082374235472334 |

| upload-photos | 1402 | 0.4313258281277862 |

| external_api::facebook | 794 | 0.7173030670704109 |

| add-photo | 1373 | 0.2622292804092885 |

| create-thumbs | 2425 | 0.09684005265383376 |

+------------------------+-----------+-----------------------+

5 rows in set (0.05 sec)

Page 21: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Timer/tag reportsMySQL [pinba]> select server_value, group_value, hit_count,

timer_value/hit_count from tag_info_group_server order by timer_value desc,

hit_count desc limit 5;

+-----------------+----------------+-----------+------------------------+

| server_value | group_value | hit_count | timer_value/hit_count |

+-----------------+----------------+-----------+------------------------+

| dphotos23 | upload-photos | 127 | 0.6577309435746801 |

| udb.mlan:9998 | hsc_connect | 105349 | 0.00042753526756620405 |

| udb.mlan:9998 | hsc_open_index | 114012 | 0.0003891547295108944 |

| dphotos30 | upload-photos | 56 | 0.7531399726867676 |

| udb.mlan:9998 | hsc_find | 98282 | 0.00042770797789420684 |

+-----------------+----------------+-----------+------------------------+

5 rows in set (0.06 sec)

Page 22: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Percentiles & Histograms

Numberof

requests

Request time

Page 23: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

PercentilesCREATE TABLE `info` (

`req_count` int(11) DEFAULT NULL,

`time_total` float DEFAULT NULL,

`ru_utime_total` float DEFAULT NULL,

`ru_stime_total` float DEFAULT NULL,

`time_interval` int(11) DEFAULT NULL,

`kbytes_total` float DEFAULT NULL,

`memory_footprint` float DEFAULT NULL,

`req_time_median` float DEFAULT NULL,

`p95` float DEFAULT NULL,

`p99` float DEFAULT NULL

) ENGINE=PINBA COMMENT='info:::95,99';

Page 24: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Report Filters

✦ Min time

✦ Max time

✦ Request tags

Page 25: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Report Filters: max_time

Request time: any, >0.1s, >0.2s, >0.3s, >0.4s, >0.5s

Page 26: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Client libraries & plugins

✦ PHP extension

✦ Nginx plugin

✦ Java client

✦ Pure PHP client

✦ Ruby client

✦ Node.js client

✦ Go client

Page 27: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Pinba in Badoo✦ PHP requests

✦ HTTP requests (nginx)

✦ Mobile apps

✦ Browser (JS) requests

✦ MySQL queries

✦ C/Go daemons

✦ Internal queues

✦ Error logs

Page 28: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

pinba.orgMore info at

Page 29: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

Thank you!

Page 30: Pinba in-memory MySQL storage engine for a full-stack real ... · Pinba in-memory MySQL storage engine for a full-stack real-time performance analytics Antony Dovgal Alexey Rybak

The original, largest and leadingdating network