why BootDev — AWS management (EC2 decrease performance by time)

In our experience, if your EC2 got resource left for a period of time, lets say 1-2 months, even AWS say it is not, but we always experience performance drop. For example: server response time drop from 400ms to 600ms . Or CPU raised from 40% to 70% in average.

In many case, many users will not 100% * 24 * 7  consume their server resources. So, in my experience, AWS want to reduce cost and reallocate some resource privately to other clients. If your server is actually low utilization, it is OK. But, in my situation, we need high response time and we reserve the CPU for that. We will feel performance drop.

How we deal with that ? That is what auto-scaling group should do. If in your auto-scaling group, your server will keep renew itself. Like turning off old servers and start new servers, the EC2 resource allocation will maintain at best performance.

Such issue especially obvious in Drupal. Drupal PHP request involve in many hooks / functions / third party calls etc. Server CPU requirement is higher than other web PHP applications. So, renewing server can help to keep better performance.

How to deploy auto-scaling group ? Call BootDev 🙂

Hope above information can help anyone that feel AWS sometimes drop performance by time 🙂

 

 

 

 

淺談叢集式電腦 ( Clustering )

當你開始接觸 clustering 時就會發覺, 原來沒學 clustering 根本等於沒有學 Unix / Linux. 
我們一般情況用到的 SERVER / Client 只是皮毛. Clustering 一個字, 內裹包含了多種技術, 
以下例子是常用的
  1. HPC – High performance computing
  2. Server Load balancing 負載平衡
    1. DNS round robin
    2. LVS – ipvsadm
  3. HA – High availability
    1. XEN cluster
    2. Heartbeat
    3. DRBD - http://www.drbd.org/
  4. Parallel computing
    1. http://en.wikipedia.org/wiki/MPICH

今天所談的是入門級的 clustering, LVS

LVS – Linux virtual server主要是用作負載平衡 與 HA,

What is the Linux Virtual Server?

The Linux Virtual Server is a highly scalable and highly available server built on a cluster of real servers, with the load balancer running on the Linux operating system. The architecture of the server cluster is fully transparent to end users, and the users interact as if it were a single high-performance virtual server.

SOURCE: http://www.linuxvirtualserver.org/ 

負載平衡的意思是把一部服務器的工作分到多部服務器之上. 由一個服務器為主人 ( Master ), 其他為幫手 ( node ). 如下圖

more_on_clustering

更可以制定負載平衡的策略

詳程參考, http://linux.die.net/man/8/ipvsadm

    1. rr – Robin Robin: distributes jobs equally amongst the available real servers.
    2. wrr – Weighted Round Robin: assigns jobs to real servers proportionally to there real servers’ weight. Servers with higher weights receive new jobs first and get more jobs than servers with lower weights. Servers with equal weights get an equal distribution of new jobs.
    3. lc – Least-Connection: assigns more jobs to real servers with fewer active jobs.
    4. wlc – Weighted Least-Connection: assigns more jobs to servers with fewer jobs and relative to the real servers’ weight (Ci/Wi). This is the default.
    5. lblc – Locality-Based Least-Connection: assigns jobs destined for the same IP address to the same server if the server is not overloaded and available; otherwise assign jobs to servers with fewer jobs, and keep it for future assignment.
    6. lblcr – Locality-Based Least-Connection with Replication: assigns jobs destined for the same IP address to the least-connection node in the server set for the IP address. If all the node in the server set are over loaded, it picks up a node with fewer jobs in the cluster and adds it in the sever set for the target. If the server set has not been modified for the specified time, the most loaded node is removed from the server set, in order to avoid high degree of replication.
    7. dh – Destination Hashing: assigns jobs to servers through looking up a statically assigned hash table by their destination IP addresses.
    8. sh – Source Hashing: assigns jobs to servers through looking up a statically assigned hash table by their source IP addresses.
    9. sed – Shortest Expected Delay: assigns an incoming job to the server with the shortest expected delay. The expected delay that the job will experience is (Ci + 1) / Ui if sent to the ith server, in which Ci is the number of jobs on the the ith server and Ui is the fixed service rate (weight) of the ith server.
    10. nq – Never Queue: assigns an incoming job to an idle server if there is, instead of waiting for a fast one; if all the servers are busy, it adopts the Shortest Expected Delay policy to assign the job.

source: Man page of ipvsadm

負載平衡方法大致上有

  1. NAT (Network address translation)
  2. DR – direct routing
  3. Tunneling

以下是 LVS – NAT LOAD BALANCING 的參考

原意圖

VS-NAT

VS via NAT, source: http://www.linuxvirtualserver.org/VS-NAT.html

指令

Master (NAT)

echo 1 > /proc/sys/net/ipv4/ip_forward

ipvsadm -A -t 192.168.7.200:80 -s rr

ipvsadm -a -t 192.168.7.200:80 -r 192.168.7.201:80 -m

ipvsadm -a -t 192.168.7.200:80 -r 192.168.7.202:80 -m

ipvsadm -a -t 192.168.7.200:80 -r 192.168.7.203:80 -m

ipvsadm -L –stats (現時的連接情況)

Nodes:

Set default route to 192.168.7.200

route add default gw 192.168.7.000

ip 地址

名稱 意思
192.168.7.200 Master
192.168.7.201 Node
192.168.7.202 Node
192.168.7.203 Node
192.168.7.1 Default GW
80 Www – web 服務器的 port number
rr Round robin 策略
-m LVS NAT
-a ADD SERVER
-A ADD SERVICE

Thanks, 有興趣多討論請跟我連絡 keithyau@yubis.net !!