zoukankan      html  css  js  c++  java
  • Load testing your environment using emproxy

    Engine Yard Docs: Load testing your environment using em-proxy

    Load testing your environment using em-proxy

    With em-proxy, a proxy built with eventmachine, you can send some real traffic to your Engine Yard Cloud environment for load testing. This allows you to test your application's performance prior to migrating giving you peace of mind that things will perform great once you do migrate. It will also allow you to compare your New Relic stats and make any needed adjustments.


    WARNING: Since you will be sending real traffic to Engine Yard Cloud using this technique you need to be absolutely sure to disable things like email and billing in your application while you test. You do not want to be double billing or spamming your users.

    Thoughbot did a great blogpost on their experience using this benchmarking technique. Additionally you can read Igvita's post on the topic as well.

    Using this example configuration, requests returning from Engine Yard Cloud will be dropped at the proxy. This will make your testing completely transparent to your end users.

    Configuration and Installation

    You perform the proxy setup and configuration on your current production servers. It resides between your load balancer and your web server. As a few adjustments will need to be made, we'll describe those in detail in a moment.

    Install The Gem and Create Your Config File

      sudo gem install em-proxy --no-ri --no-rdoc
    
    

    Create a proxy.rb file to the root users home directory.

    Update Nginx

    Since em-proxy will be running on port 80, nginx will have to run on port 8080. Change your nginx vhost listening on port 80 to port 8080, then restart nginx using /etc/init.d/nginx restart command.

    Start The Proxy

    Start the proxy up on one server at a time, if you run into issues along the way it will be much easier to back out any changes.

    Run the proxy.rb inside of a screen session.

      $ screen
    $ ruby proxy.rb
    
    

    To detach from the screen session simply hit ctrl+a+d and you will detach.

    To later resume the screen session:

      $screen -x
    
    

    The proxy will start up and start taking traffic on port 80. It will proxy traffic to nginx, locally, on port 8080

    Test The Setup

    Make sure you can curl your app and receive the response you expect.

      $ curl -H host:yourhostname.com http://localhost
    
    

    Disabling The Proxy

    To turn the proxy off:

    • First kill the ruby process you fired up.
    • Next revert the nginx config changes so that your vhosts are listening on port 80 instead of port 8080.
    • Then restart nginx using the command: /etc/init.d/nginx restart

    Now you are back to your default configuration.

    Example Code

    An example of proxy.rb

      `#` proxy.rb
    require 'em-proxy'
    
    Proxy.start(:host => "0.0.0.0", :port => 80) do |conn|
      conn.server :production, :host => '127.0.0.1', :port => 8080
      conn.server :ey_cloud, :host => '192.0.32.10', :port => 80
      conn.on_data do |data|
        data
      end
      conn.on_response do |server, resp|
        resp if server == :production
      end
    end
    
    

    Let's step through this script and describe

  • 相关阅读:
    Oracle 安装报错 [INS-06101] IP address of localhost could not be determined 解决方法输入日志标题
    Linux下安装oracle数据库提示DISPLAY not set. Please set the DISPLAY and try again。
    redhat 关机注销命令详解
    VirtualBox的四种网络连接方式
    修改RedHat的系统显示时间
    insufficient memory to configure kdump(没有足够的内存)解决方法(待验证、待解决)
    xen坑随笔 heartbeat dpkg垃圾数据库清除
    tomcat 监控脚本
    负载均衡随笔
    GIT命令介绍
  • 原文地址:https://www.cnblogs.com/lexus/p/2374959.html
Copyright © 2011-2022 走看看