網頁

2016年7月14日 星期四

Test transaction page performance

Usually we test web page performance. Maybe test 1000 with 5 concorrent.
If we test a transaction page performance. Will left many ugly transaction data.
So we can desgin a dryrun mode. below is ruby on rails sample.


  1. <pre>  class PurchasesController < ApplicationController
  2.     def create
  3.       ActiveRecord::Base.transaction do
  4.         # This do purchase
  5.         raise ActiveRecord::Rollback if params[:dryrun] # when dryrun then rollback.
  6.       end
  7.     end
  8.   end
  9. </pre>

2016年7月13日 星期三

Ruby method / block / yield / Proc / lambda 全面解釋

http://railsfun.tw/t/method-block-yield-proc-lambda/110

2016年7月12日 星期二

Nginx Reverse proxy from VirtualHost to VirtualHost

www.demo.com DNS is go to Server1. /and Reverse proxy to Server2 by server2.demo.com . But Server2 need to known www.demo.com. So we need set header by proxy_set_header.

**Server1**
```
server {
  listen 80;
  server_name www.demo.com;

  location / {
      proxy_set_header Host $host;
      proxy_pass http://server2.demo.com/;
  }
}

```


**Server2 server2.demo.com**
```
server {
    listen 80;
    server_name www.demo.comt;
    root /opt/www/;
    index index.html index.htm;
}
```