Benchmark:系统的瓶颈
    测量应用现有的性能
    校验系统可扩展性:通过增加压力测试
    估算业务增长后,对硬件 资源 网络的需求
    测试系统对环境变化的容忍度:短暂的并行峰值、服务器的配置改变
    不同硬件 软件 操作系统 raid的影响:硬盘ata/san
Benchmark策略:
    fullstack:整个应用作为一个整体
    single-component:隔离的mysql
    Goal:TPS(transaction per second), 反应时间,压力,并发
Benchmark方法:
    错误方法:数据量不够、单用户、
    正确方法:
Benchmark tool:
    full-stack(ab http_load jMeter)
    single-component(mysqlslap sysbench mysql-bachmark-suite super-smack)
   
   
profiling: 应用程序消耗最多时间和资源的地方
1. 应用profile:开发过程记录,页面的时间,io时间等等
2. mysql profile:
    哪些数据访问最多
    哪些sql执行最多
    那种state mysql thread执行时间最长
    那种subsystem mysql执行query时间最长
    mysql在query期间都访问了哪些数据
    在query期间都做了哪些活动,比如index scan
3. logging:两种 一种general log,一种slow log(记录查询时间大于2s的query,可配置)
    mysql从5.0开始,long_query_time=10000,只有大于此数量的query才会记录,其实变相禁用slow query
    general log没有query用时信息
    5.0的slowlog 只能以秒为单位,但对于高性能应用这个粒度不够
    slow log分析工具:mysql_slow_log_filter mysql_slow_log_parser mysqlsla
mysql server profile: show session status:
        Bytes_received and Bytes_sent
            The traffic to and from the server
        Com_*
            The commands the server is executing
        Created_*
            Temporary tables and files created during query execution
        Handler_*
            Storage engine operations
        Select_*
            Various types of join execution plans
        Sort_*
            Several types of sort information


Profling Queries with SHOW STATUS
1. 使用flush status和show session status分析query
2. flush status; select sql_no_cache id from table;
    show session status like 'Select*':全表扫描 全表join 子表rangeScan
    show session status like 'Handler*':存储引擎的操作,读写次数,写可能是由于有Group/OrderBy操作导致的临时表
    show session status like 'Sort*':Group/OrderBy操作导致的排序
    show session status like 'Create*':

       上面导致的建立临时表的个数,不同的版本是不一样的,
       mysql4是共享参数,可能会被其他session修改
                                       
Profling Queries with SHOW PROFILE
1. set profiling=1;
2. show profile;
   show profile cpu for query 1;