apache安裝Apr的做用

1.什麼是APR 
要測APR給tomcat帶來的好處最好的方法是在慢速網絡上(模擬Internet),將Tomcat線程數開到300以上的水平,而後模擬一大堆併發請求。若是不配APR,基本上300個線程狠快就會用滿,之後的請求就只好等待。可是配上APR以後,併發的線程數量明顯降低,從原來的300可能會立刻降低到只有幾十,新的請求會毫無阻塞的進來。APR對於Tomcat最大的做用就是socket調度。你在局域網環境測,就算是400個併發,也是一瞬間就處理/傳輸完畢,可是在真實的Internet環境下,頁面處理時間只佔0.1%都不到,絕大部分時間都用來頁面傳輸。若是不用APR,一個線程同一時間只能處理一個用戶,勢必會形成阻塞。因此生產環境下用apr是很是必要的。 
2.配置ws協議的反向代理web

RewriteEngine On RewriteCond %{HTTP:Upgrade} =websocket RewriteRule /(.*) ws://localhost:9001/api/$1 [P,L] RewriteCond %{HTTP:Upgrade} !=websocket RewriteRule /(.*) http://localhost:9001/api/$1 [P,L]
  • 1
  • 2
  • 3
  • 4
  • 5

2.1配置http反向代理apache

<VirtualHost *:80> ServerAdmin test@test.com ServerName www.test.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common ProxyRequests Off <Proxy /test> Order deny,allow Allow from all </Proxy> ProxyPass /test http://www.reverse.com/proxy ProxyPassReverse /test http://www.reverse.com/proxy </VirtualHost>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

3.配置http正向代理api

<VirtualHost *:80> ServerAdmin prograsliu@gmail.com DocumentRoot "D:/www/test" ServerName www.test.com ServerAlias test.com ErrorLog "logs/test.com-error.log" CustomLog "logs/test.com-access.log" common Alias /sublook "D:/www/test/look/sublook/" <Directory "D:/www/test"> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> #正向代理設置 ProxyRequests On ProxyVia On <Proxy *> Order deny,allow Deny from all Allow from 127.0.0.1 </Proxy> </VirtualHost>
相關文章
相關標籤/搜索