Squid最佳化完全手冊(1)(轉)
Squid最佳化完全手冊(1)(轉)[@more@]一、 概述squid是一款優秀的open source的代理伺服器軟體,可以執行於多種系統平臺上,但是同其他商業化的產品相比,其缺點也是很明顯的,那就是它的命中率和效率相對低下。本文主要討論在不改變硬體條件之下,透過以下手段對squid進行效能最佳化:1. 編譯一個高效的、精簡的新核心;2. 對Cache分割槽採用reiserfs日誌檔案系統;3. 重新編譯squid;4. 最佳化squid配置;對於最佳化的效果,我使用大名鼎鼎的cacheflow公司的測試工具——cfmc進行測試比較:首先用cfmc自帶的一個指令碼,從squid.conf的access.log中抽出RUL,然後以這些RUL為依據進行測試。伺服器配置:型號:HP LH3CPU:PII450記憶體:256MB 100MHz ECC SDRAM DIMM硬碟:9.1GB Hot-Swap Ultra2 Hard Disk網路卡:Ethernet Express PRO 100 10/100M X 2作業系統:RedHat 7.1最佳化前測試結果:Iteration 0: Cumulative statistics; 933 seconds elapsedTotal objects: 72599, total object size: 513211102 bytesAverage object size: 7069 bytesAverage object response time: 2707 millisecondsObjects per second: 77.81Bytes per second: 550065, min: 550065, max: 879873URLs discarded due to socket or connection failures: 6955Redirections: 1017, Cookied objects: 1036Pragma no-cache objects: 1656, Non-200 HTTP response codes: 2505最佳化後測試結果:Iteration 0: Cumulative statistics; 688 seconds elapsedTotal objects: 72599, total object size: 403833100 bytesAverage object size: 5562 bytesAverage object response time: 1890 millisecondsObjects per second: 105.52Bytes per second: 586966, min: 586966, max: 995582URLs discarded due to socket or connection failures: 16372Redirections: 1658, Cookied objects: 1000Pragma no-cache objects: 1454, Non-200 HTTP response codes: 3132透過對以上測試結果的比較,我們可以看出:最佳化後的Objects per second增加了35.6%,Average object response time減少了43.2%,對整體效能的提升還是比較明顯的。二、 編譯新核心我們採取這樣的方式來編譯核心:取消核心的模組支援,將伺服器所有的硬體驅動編譯到核心中,此外還要注意將對reiserfs檔案系統的支援也編譯到核心中,從而在提供系統效能的同時增加系統安全性。在2.4.10以上的版本中,已經內建了對reiserfs檔案系統的支援。首先從下載linux-2.4.12.tar.gz,這是當前最新的核心。然後解開核心檔案:tar xvzf linux-2.4.12.tar.gz進入新生成的目錄並執行:cd linuxmake mrpropermake config根據我的伺服器的配置,我選擇這樣編譯核心:* Code maturity level optionsPrompt for development and/or incomplete code/drivers (CONFIG_EXPERIMENTAL) [Y/n/?]* Loadable module supportEnable loadable module support (CONFIG_MODULES) [N/y/?]* Processor type and featuresProcessor family (386, 486, 586/K5/5x86/6x86/6x86MX, Pentium-Classic, Pentium-MMX, Pentium-Pro/Celeron/Pentium-II, Pentium-III/Celeron(Coppermine), Pentium-4, K6/K6-II/K6-III, Athlon/Duron/K7, Crusoe, Winchip-C6, Winchip-2, Winchip-2A/Winchip-3, CyrixIII/C3) [Pentium-Pro/Celeron/Pentium-II]* General setupNetworking support (CONFIG_NET) [Y/n/?]PCI support (CONFIG_PCI) [Y/n/?]PCI access mode (BIOS, Direct, Any) [Any]defined CONFIG_PCI_GOANYPCI device name database (CONFIG_PCI_NAMES) [Y/n/?]System V IPC (CONFIG_SYSVIPC) [Y/n/?]Sysctl support (CONFIG_SYSCTL) [Y/n/?]Kernel core (/proc/kcore) format (ELF, A.OUT) [ELF]defined CONFIG_KCORE_ELF* Plug and Play configurationPlug and Play support (CONFIG_PNP) [Y/n/?]* Block devicesNormal PC floppy disk support (CONFIG_BLK_DEV_FD) [Y/n/?]* Networking optionsKernel/User netlink socket (CONFIG_NETLINK) [Y/n/?]Routing messages (CONFIG_RTNETLINK) [Y/n/?]Network packet filtering (replaces ipchains) (CONFIG_NETFILTER) [Y/n/?]Unix domain sockets (CONFIG_UNIX) [Y/n/?]TCP/IP networking (CONFIG_INET) [Y/n/?]IP: advanced router (CONFIG_IP_ADVANCED_ROUTER) [Y/n/?]IP: policy routing (CONFIG_IP_MULTIPLE_TABLES) [Y/n/?]IP: use netfilter MARK value as routing key (CONFIG_IP_ROUTE_FWMARK) [Y/n/?]IP: fast network address translation (CONFIG_IP_ROUTE_NAT) [Y/n/?]IP: equal cost multipath (CONFIG_IP_ROUTE_MULTIPATH) [Y/n/?]* IP: Netfilter ConfigurationConnection tracking (required for masq/NAT) (CONFIG_IP_NF_CONNTRACK) [Y/n/?]FTP protocol support (CONFIG_IP_NF_FTP) [Y/n/?]IP tables support (required for filtering/masq/NAT) (CONFIG_IP_NF_IPTABLES) [Y/n/?]limit match support (CONFIG_IP_NF_MATCH_LIMIT) [Y/n/?]Multiple port match support (CONFIG_IP_NF_MATCH_MULTIPORT) [Y/n/?]Connection state match support (CONFIG_IP_NF_MATCH_STATE) [Y/n/?]Packet filtering (CONFIG_IP_NF_FILTER) [Y/n/?]Full NAT (CONFIG_IP_NF_NAT) [Y/n/?]REDIRECT target support (CONFIG_IP_NF_TARGET_REDIRECT) [Y/n/?]LOG target support (CONFIG_IP_NF_TARGET_LOG) [Y/n/?]ATA/IDE/MFM/RLL support (CONFIG_IDE) [Y/n/?]* IDE, ATA and ATAPI Block devicesEnhanced IDE/MFM/RLL disk/cdrom/tape/floppy support (CONFIG_BLK_DEV_IDE) [Y/n/?]Include IDE/ATA-2 DISK support (CONFIG_BLK_DEV_IDEDISK) [Y/n/?]Use multi-mode by default (CONFIG_IDEDISK_MULTI_MODE) [Y/n/?]Include IDE/ATAPI CDROM support (CONFIG_BLK_DEV_IDECD) [Y/n/?]* SCSI supportSCSI support (CONFIG_SCSI) [Y/n/?]* SCSI support type (disk, tape, CD-ROM)SCSI disk support (CONFIG_BLK_DEV_SD) [Y/n/?]Maximum number of SCSI disks that can be loaded as modules (CONFIG_SD_EXTRA_DEVS) [8]* Some SCSI devices (e.g. CD jukebox) support multiple LUNsEnable extra checks in new queueing code (CONFIG_SCSI_DEBUG_QUEUES) [Y/n/?]* SCSI low-level driversAMI MegaRAID support (CONFIG_SCSI_MEGARAID) [Y/n/?]SYM53C8XX SCSI support (CONFIG_SCSI_SYM53C8XX) [Y/n/?]default tagged command queue depth (CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS) [4]maximum number of queued commands (CONFIG_SCSI_NCR53C8XX_MAX_TAGS) [32]synchronous transfers frequency in MHz (CONFIG_SCSI_NCR53C8XX_SYNC) [80]* Network device supportNetwork device support (CONFIG_NETDEVICES) [Y/n/?]* Ethernet (10 or 100Mbit)Ethernet (10 or 100Mbit) (CONFIG_NET_ETHERNET) [Y/n/?]EISA, VLB, PCI and on board controllers (CONFIG_NET_PCI) [Y/n/?]EtherExpressPro/100 support (CONFIG_EEPRO100) [Y/n/?]* Input core supportInput core support (CONFIG_INPUT) [Y/n/?]Keyboard support (CONFIG_INPUT_KEYBDEV) [Y/n/?]* Character devicesVirtual terminal (CONFIG_VT) [Y/n/?]Support for console on virtual terminal (CONFIG_VT_CONSOLE) [Y/n/?]Standard/generic (8250/16550 and compatible UARTs) serial support (CONFIG_SERIAL) [Y/n/?]Unix98 PTY support (CONFIG_UNIX98_PTYS) [Y/n/?]Maximum number of Unix98 PTYs in use (0-2048) (CONFIG_UNIX98_PTY_COUNT) [8]* File systemsReiserfs support (CONFIG_REISERFS_FS) [Y/n/?]ISO 9660 CDROM file system support (CONFIG_ISO9660_FS) [Y/n/?]/proc file system support (CONFIG_PROC_FS) [Y/n/?]/dev/pts file system for Unix98 PTYs (CONFIG_DEVPTS_FS) [Y/n/?]* Console driversVGA text console (CONFIG_VGA_CONSOLE) [Y/n/?]這裡需要說明的是:如果要使用透明代理模式,要仔細選擇Netfilter,因為我們還得用iptables來重定向tcp包,以滿足透明代理的要求。假如您的伺服器配置與我的不同,只需要更改相應的硬體配置引數即可,比如CPU型別、網路卡、SCSI硬碟等。接著:make bzImage完成後,將 arch/i386/boot/目錄下的新核心bzImage複製到/boot/目錄下,並更名為opt:cp arch/i386/boot/bzImage /boot/mv /boot/bzImage /boot/opt然後編輯lilo.conf如下所示:boot=/dev/sdamap=/boot/mapinstall=/boot/boot.bprompttimeout=50message=/boot/messagedefault=optimage=/boot/vmlinuz-2.4.2-2label=linuxinitrd=/boot/initrd-2.4.2-2.imgread-onlyroot=/dev/sda1image=/boot/optlabel=optread-onlyroot=/dev/sda1最後執行:# liloAdded linuxAdded opt *好了,這樣我們就可以用新核心啟動了,您可以發現,這樣自己編譯的核心要小的多,也快得多
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8225414/viewspace-940637/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Squid最佳化完全手冊(轉)UI
- Squid最佳化完全手冊(2)(轉)UI
- FVWM安裝完全手冊(轉)
- PHPNuke完全安裝手冊(轉)PHP
- WindowsXP組策略應用完全手冊(轉)Windows
- Linux不完全手冊(三)(轉)Linux
- Linux不完全手冊(二)(轉)Linux
- Linux完全自學手冊Linux
- Fvwm新手入門不完全手冊(原創) (轉)
- CSS垂直水平完全居中手冊CSS
- ASP網路安全手冊(1) (轉)
- SQL 最佳化手冊SQL
- oracle11g dataguard 完全手冊Oracle
- PHP正規表示式完全手冊PHP
- oracle 11g dataguard 完全手冊Oracle
- D版 Rational Rose 2001 完全安裝手冊 (轉)ROS
- MaxPHP(原Yao框架)完全開發手冊PHP框架
- oracle11g dataguard完全手冊--switchoverOracle
- EBS R12 安裝完全手冊
- Linux網路管理員手冊(1) (轉)Linux
- 十分鐘玩轉3D繪圖:WxGL完全手冊3D繪圖
- 您有一份ThreadLocal完全解析手冊thread
- JavaScript完全參考手冊第3版pdfJavaScript
- Go net/http 超時機制完全手冊GoHTTP
- 小程式 音訊API採坑完全手冊音訊API
- NSubstitute完全手冊(十)清理已收到的呼叫
- Global.asa程式設計完全參考手冊程式設計
- [譯] Swift 網路單元測試完全手冊Swift
- 透明防火牆架設的完全攻略(bridge+iptables+squid)(轉)防火牆UI
- iptables中文手冊(轉)
- 你還沒有聽過React不完全手冊???React
- ARM系列處理器應用技術完全手冊
- Linux 管理員手冊(1)--Linux系統概述(轉)Linux
- FFMpeg SDK 開發手冊 1
- oracle函式手冊(轉)Oracle函式
- aptitude 簡明手冊(轉)APT
- RPM命令手冊 (轉)
- Squid 工作的原理(轉)UI