zoukankan      html  css  js  c++  java
  • Notes on <High Performance MySQL> Ch10: ApplicationLevel Optimization

    Chapter 10: Application-Level Optimization

    Application Performance Overview

    Find the Source of the Problem

    Add profiling capabilities to your application.

    Look for Common Problems

    -          What’s using the CPU, disk, network, and memory resources on each of the machine involved?

    -          Is the application really using all the data it’s getting?

    -          Is the application doing processing that ought to be done in the database, or vice versa?

    -          Is the application doing too many queries?

    -          Is the application doing too few queries?

    -          Is the application connecting to MySQL unnecessary?

    -          Is the application connecting too many times to the same MySQL instance, perhaps because different parts of the application open their own connections?

    -          Is the application doing a lot of “garbage” queries?

    -          Does the application use a connection pool?

    -          Does the application use persistent connections?

    -          Is the application holding connections open even when it’s not using them?

    -           

    Web Server Issues

    Finding the Optimal Concurrency

    For a CPU-bound workload, the optimal concurrency is equal to the number of CPUs (or CPU cores). However, processes are not always runnable, because they make blocking calls such as I/O, database queries, and network requests. Therefore, the optimal concurrency is usually higher than the number of CPUs.

    Caching

    You can think about caches in two broad categories: passive caches and active caches. Passive caches do nothing but store and return data. When you request something from a passive cache, either you get the result or the cache tells you “that doesn’t exist.” An example of a passive cache is memcached.

    In contrast, an active cache does something when there’s a miss. It usually passes your request on to some other part of the application, which generates the requested result.  The active cache then stores the result and returns it. The Squid caching proxy server is an active cache.

    Caching Below the Application

    Application-Level Caching

    An application-level cache typically stores data in memory on the same machine, or across the network in another machine’s memory.

    -          Local caches

    -          Local shared-memory caches

    -          Distributed memory caches

    The best-known example of a distributed memory cache is memcached. Distributed caches are much larger than local shared-memory caches and are easy to grow. Only one copy of each bit of cached data is created.

    -          On-disk caches

    One very useful trick with on-disk caches and web servers is to use 404 error handlers to catch cache misses.

    Cache Control Policies

    -          TTL (time to live)

    The cached object is stored with an expiration date. This invalidation policy is best for data that changes rarely or doesn’t have to be fresh.

    -          Explicit invalidation

    There are two variations of this policy: write-invalidate and write-update.

    -          Invalidation on read

    Instead of invalidating stale data when you change the source data from which it’s derived, you can store some information that lets you determine whether the data has expired when you read it from the cache.

    Cache Object Hierarchies

    Pre-generating Context

     Extending MySQL

    Alternatives to MySQL

  • 相关阅读:
    同样的请求img代码,单个html文件和项目中的html文件请求结果不一样
    CSS中A标签断字不换行问题(基础知识)
    句柄无效。 (异常来自 HRESULT:0x80070006 (E_HANDLE))
    Ext.Net 控件FileUploadField上传文件
    500内部服务器错误。你查找的资源存在问题,因而无法显示
    WebService 错误:无法加载协定为xxx的终结点配置部分,因为找到了该协定的多个终结点配置
    SyntaxError: unterminated string literal
    servlet入门
    myeclipse视图布局恢复
    JavaWEB开发入门
  • 原文地址:https://www.cnblogs.com/fangwenyu/p/2669424.html
Copyright © 2011-2022 走看看