[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ 17 ] [ A ] [ B ] [ C ] [ D ] [ E ] [ next ]

Smart Cache Manual
Chapter 9 - For Administrators


9.1 Smart Cache Performance

Smart Cache runs fast and has comparable performance with other (non-Java) proxy servers, such as Apache or Squid. Proxy servers do not needs much CPU power and real world performance is limited by filesystem and network speeds.

One active browsing user needs about 50-60 pages/min (if network bandwidth is not a limiting factor). So 486/33 with Linux can serve 15 users without any problems, if there is sufficient amount of installed RAM (20MB) and machine do not run any CPU-intensive tasks on normal or high priority.

I have used this configuration for 2 years on OS/2 which is even slower on filesystem operations than Linux. Nowadays it means than any Pentium class low end system can do proxy for whole network without troubles. I am using Pentium 166, 64 MB RAM, Debian Linux 3.0, reiserfs 3 filesystem mounted with notail as proxy server for 50 users. In following two sections you will find how it performs on low-end hardware.


9.1.1 Case study #1 - 486/33 OS/2

On my old 486/33DX System with 20MB RAM running JDK1.1.4 under OS/2 (JIT off), Smart Cache serves 350 pages/min (with JIT is under OS/2 about 25% faster, but sometimes crashes due to JIT bug). OS/2 port of Apache 1.1 server only about 250.


9.1.2 Case study #2 - 486/100 Linux

On Linux 486 100Mhz system with JDK1.1.7 with tya1.1 JIT and green threads it serves 910 pages/min. Do not use native threads under Linux's Java 1.1, it is buggy, slow and memory hungry.

Linux can use different filesystems. Do not use vfat unless you need to share your cache with Windows running on the same machine. In my benchmarks i have found that reiser fs (especially with notail) is much faster than ext2 and because it can pack small files together into one disk block, i really recommend it for running large cache.


9.2 Proxy cache Benchmarks

Hardware used: Pentium 166/32MB RAM, IDE hard drive (hdparm -t 7.8MB), Debian Linux 3.0, kernel 2.4.19, reiserfs 3.6.25 filesystem.

Software used: Sun JDK 1.1.8v1, tya JIT 1.7v2, webbench 1.2, Apache 1.3.24, GCJ-3.2, Squid 2.4.6, Smart Cache 0.77pre.

Test method: The benchmark was simple `give me the same page` test. I have run every test 3 times; highest number was recorded. Smart Cache configuration: -nolog -notrace -nofail -local. Other software has defaults. Test page was 38314 Bytes long. Numbers are in pages/min. The test execution time was 15 seconds.

     Results:
     ========
     
     smartcache-gcj 6512
     Squid 4528
     Apache Cache 3980
     Apache from localhost 3808
     
     Virtual machine: jdk 1.1.8v1 with green threads.
     
     no JIT              tya JIT
     
     default 2856            4500
     -ms1m   2792            4064
     -ms2m   3092            5348
     -ms3m   3768            5432
     -ms4m   3932            5468
     -ms5m   3976            5504 
     -ms6m   4048            5460
     -ms7m   4068            5592

These tests was before -local switch fix. These patches adds 4% to Smart Cache results. They should be used if you want to get comparable results.


9.3 Administration of large cache

Garbage collection on large caches can take some time. Art of administration large SC is to tweak gc.cnf values and then clear daily files with single scan garbage collection. How can you do it?

Smart Cache GC deletes by one cache scan at most gcarraysize objects + number of too old objects. You must make gcarray size to be large enough for holding your daily traffic minus files which has been delete during scan. Average file size is in most cases about 10kB; If you have 100MB daily traffic, set gcsize to 10000. The GC runs best when gcarraysize is power of two. Making bigger gcarraysize cost more CPU (not problem today) and memory during GC. If you make gcarray size too big and OS will needs to start swaping, GC will run very slow or runs out of memory.

Because size of gcarray is never big enough. Use settings like that for forcing fast cleaning of non-checkable and other junk pages during cache scan; it will save you valueable gcarraysize. Also is a very good idea to set reference_age to some smaller value, for example 90.

     negative_cached_penalty =0.5
     expired_penalty =0.5
     expired_but_checkable_penalty +0
     redirect_penalty =0.5
     not_checkable_penalty =0.5
     reference_age 90

9.4 Making native executable

Smart Cache runs when it is recompiled with GCJ to native executable. I have tested GCJ 3.2 and there are no problems with it. This native executable runs faster (at least on Linux), but eats more memory.

You can build Debian GCJ compiled package scache-native directly from sources.


9.5 Smart Cache vs Squid

Squid and Smart Cache are not competing products. Both uses different designs; Apache Web server cache uses SC design also. This chapter will show some differences. In short Squid needs huge amounts of RAM.


9.6 Smart Cache memory usage

Smart Cache has been optimised for minimal RAM and CPU use. In normal use (by single browsing user), it requires only about 400Kb RAM from JVM. To get total size of required memory, you must add the shared dynamic (DLL) code loaded by the Java Runtime itself, which depends on Java versions, Java runtime options and operation system used.


9.6.1 Linux hints

On Linux with Blackdown JDK1.1.7 disable Motif Java interface (export NS_JAVA=true). You will need only about 2.2MB of physical RAM (green threads without JIT) or 2.7MB of physical RAM with tya JIT. When Smart Cache is in heavy use by multiple users add 350-500k.


9.6.2 OS/2 hints

On OS/2 Smart Cache takes about 3.5-4.5MB RAM, it can be reduced by factor 2 using excellent LXOPT utility on Java's DLLs. LXOPT utility is freeware now. See LXOPT documentation for more info.

Another memory gain is to add -norestart option just before -ms1m on Java invocation commandline. This do not starts another copy of Java with PM libraries (used for AWT).


9.7 Web forwarding with Smart Cache

This is the setup for the web forwarder from www.firma.cz to www-orig.firma.cz. Smart Cache runs on www.firma.cz and forwards requests to www-orig.firma.cz. Some people use term web accelerator instead forwarder.

Web forwarders are useful for example if you need to maintain your WWW site locally, but have a slow line and many users, so put the forwarder on the ISP backbone, people will use forwarder, and forwarder will send back cached data from your server. Forwarder is also good when website uses dynamically-generated web-pages. If you have many users then many same pages must be generated for every request, which uses valuable CPU resources.

     BindAddress *
     Fail *
     Pass http://www-orig.firma.cz/*
     default_forward_for www.firma.cz
     Redirect http://www.firma.cz/* http://www-orig.firma.cz/*
     access_log http://www.firma.cz/*  firma.log
     NoCaching */cgi-bin/*
     default_refresh_pattern 15 60 0.20 5000
     pragma_no_cache 0

9.8 Using Smart Cache as transparent proxy

Smart Cache can be also used in transparent-proxy mode. Unlike Squid, Smart Cache does all security checks and you will not open new security hole. [6] You don't have to setup anything in scache.cnf, but you need TCP/IP stack or router hardware/software, which allow transparent proxying. Linux or Cisco operations systems can do that.

TCP-IP must be configured to redirect all traffic with destination port 80 to your Smart Cache's input port (same as for normal proxy requests). This configuration is operation system dependent, ask your network administrator for doing it.

In Linux, this is done with ipfwadm/ipchains/iptables programs. Consult NAT-HOWTO for more information.


9.9 Using cache directory swaplevels

SC by default uses 4x4 swap directory levels. If you look into it and see, that there are many (about 100) subdirectories with server names it may be wise to increase swap_level1/2_dirs and than redistribute directories to new levels using -rebalance command line option.

For classic design filesystems which does not uses trees for indexing directory (ext2,fat) there should not be more than 100 subdirectories. Modern filesystems hpfs, ntfs, reiserfs, xfs can handle more without any performance problems. See scache.cnf for cachesize vs swaplevels table.


9.10 Setting the bindaddress

BindAddress is default set up to 127.0.0.1. Many people do not need access SmartCache from others computers and this also closes access from Internet to your computer or LAN via Smart Cache, which is a Good Thing. No other computers can connect to it. This is very good for security, but not very useful if you have LAN.

If you have an Intranet and want to allow other Intranet computers to connect, enter your Intranet IP address here.

Magic '*' allows any computer (even from Internet) to connect and use your proxy. If you use it, blocking some URLs in you private network will be wise (see URL blocking, Section 5.6). There are no known security holes.

For fine-tuning access to your proxy server see Proxy access control, Section 9.11.


9.11 Proxy access control

Proxy access may be limited by using "allow" configuration statement with the host ip address as a parameter to grant access only to specified hosts. Hosts that are not allowed to access proxy server will receive "403 Cache access denied" response. If no "allow" statements are found then any host is allowed to access the proxy.

Allow statement can have optionally netmask or number of bits appended.

     Example:
     # allow proxy access only from computer it is running at and from addresses
     # 192.168.1.2 and 192.168.1.3
     allow 127.0.0.1/8
     allow 192.168.1.2/255.255.255.255
     allow 192.168.1.3

[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ 12 ] [ 13 ] [ 14 ] [ 15 ] [ 16 ] [ 17 ] [ A ] [ B ] [ C ] [ D ] [ E ] [ next ]

Smart Cache Manual

0.84
Radim Kolar hsn@cybermail.net