15
APC Some useful tuning

Apc optimization

Embed Size (px)

DESCRIPTION

Talking a

Citation preview

Page 1: Apc optimization

APCSome useful tuning

Page 2: Apc optimization

2 caching mechanism

Memory cache for long operations and calculations

Opcode cache for skipping code interpretation

Page 3: Apc optimization

Opcode

The Vulcan Logic Disassembler

Page 4: Apc optimization

Tuning opcode cache

apc.max_file_size (1M)Files bigger then that wouldn't be cached.

apc.num_files_hint (1000)Number of files that will be cached. Increase it.

apc.file_md5 (0)Keep it 0, it's a lie

apc.ttl (0)How long the file will stay cached

Page 5: Apc optimization

Tuning opcode cache

apc.stat (1)Rechecking if file was updated. Set it to 0.

Page 6: Apc optimization

Tuning opcode cache

strace -e trace=file httpd -X

Page 7: Apc optimization

Tuning opcode cache

apc.stat (1)Rechecking if file was updated. Set it to 0.

apc.slam_defense (1)Prevents mass caching on startup. Set to 0

apc.write_lock (1)Prevents locking of parallel requests

apc.file_update_protection (2)Seconds to wait before new file gets cached

Page 8: Apc optimization

Extra control on opcode caching

apc.filter (null)Regexp: cache only matching it files.

apc.cache_by_default (1)Caches all php files. If set to 0 - it would use the filter

apc.canonicalize (1)Convert relative path's into canonical. Set to 0 and always use absolute path's.

Page 9: Apc optimization

Now User Cache

Page 10: Apc optimization

Concurrent lockingFile locksBasic locking mechanism. Very slow.

IPC Semaphore locksSemaphores (provided by the OS). Better then file locks

Linux Futex locksLinux specific mechanism. Significant gain. ( user space )

Pthread mutexesAlmost same as futex ( kernel space)

Spin locksExtremely fast. Ported from Postgres. Eats your cpu

Page 11: Apc optimization
Page 12: Apc optimization

Use igbinarySerialization sucksExample array: [1,2,'hi']

Page 13: Apc optimization

Use igbinary

Page 14: Apc optimization

Apc constants

Regular defines are uber slow

Page 15: Apc optimization

Prime cache before start

Preload cache with data before going public

apc_store()apc_compile_file()