PDA

View Full Version : Trying to use APC but it seems to be clearing out?


NUTNDUN
06-17-2011, 08:38 AM
I am very new to Litespeed but I must say I have been hugely impressed by it's performance. We went from a dedicated server with server loads around 1 to a vps hybrid and using Litespeed and server loads barely go over .30.

I am trying to use some sort of cache and have found a lot of conflicting information in what can or can't be used.

I would like to use APC or xcache. I have them both installed and they both work to an extent. Both seem to reset after so many seconds or minutes almost like the web server is restarted.

I am only trying one at a time, as I know you can't have two opcode caches running at the same time. I also have php suexec enabled for users home directory in the configuration for litespeed.

It is a CentOS server using Cpanel. Any help would be appreciated.

webizen
06-17-2011, 09:44 AM
For either opcode cache to work, php suEXEC needs to be disabled (Admin Console -> Configuration -> Server -> General -> Load Apache Configuration File -> PHP suEXEC => No)

NUTNDUN
06-17-2011, 09:50 AM
I did turn the suEXEC option off last night and was using xcache and it still seemed like it was resetting every 30 seconds to a minute. When I first set it like that last night it seemed like it was working good and had over 35,000 hits showing and then it reset and after that it seemed to reset about every minute.

webizen
06-17-2011, 10:47 AM
With PHP suEXEC off, PHP runs as Webserver user (dedicated hosting) instead of individual account user. Opcode cache would _not_ work in the shared hosting environment. It resets frequently in shared environment as you described.

Please turn suEXEC off and see issue re-appears.

NUTNDUN
06-17-2011, 12:18 PM
Ok, I turned suEXEC off and turned xcache back on.

About every 10 minutes or so it is like it is resetting. All of the hits that are showing on the xcache admin along with memory usage get cleared out and starts over again.

Here are my settings displayed in xcache admin:
Version 1.3.2
Modules Built cacher
Readonly Protection N/A
Cache Init Time 2011-06-17 14:15:29
Cache Instance Id 28592
Opcode Cache enabled, 134,217,728 bytes, 1 split(s), with 8192 slots each
Variable Cache enabled, 33,554,432 bytes, 1 split(s), with 8192 slots each
Shared Memory Schemes mmap

Directive Local Value Master Value
xcache.admin.enable_auth On On
xcache.cacher On On
xcache.coredump_directory no value no value
xcache.count 1 1
xcache.gc_interval 300 300
xcache.mmap_path /dev/zero /dev/zero
xcache.readonly_protection 1 1
xcache.shm_scheme mmap mmap
xcache.size 128M 128M
xcache.slots 8K 8K
xcache.stat On On
xcache.test no value no value
xcache.ttl 3600 3600
xcache.var_count 1 1
xcache.var_gc_interval 300 300
xcache.var_maxttl 7200 7200
xcache.var_size 32M 32M
xcache.var_slots 8K 8K
xcache.var_ttl 3600 3600

NUTNDUN
06-17-2011, 12:33 PM
I just upped the size of the shared memory to 64MB and set the xcache.size to 48MB to see if that makes any difference. The kernel was set to 32MB originally. I am only guessing that it was clearing it out because of filling the shared memory?

NUTNDUN
06-17-2011, 04:11 PM
The new memory settings at first seemed like it was working but it still ends up resetting itself. I don't know it if it litespeed that is restarting or what might be causing it. I don't know enough to figure out what to look for that would be causing it.

NUTNDUN
06-17-2011, 05:22 PM
I wanted to try APC also and it is doing the same thing. Resetting way before the ttl setting would kick in.

NiteWave
06-17-2011, 11:27 PM
what's the APC settings in php.ini ?

NUTNDUN
06-18-2011, 03:56 AM
Here are my settings for APC:
------------------
extension="apc.so"
apc.shm_size="128M"
apc.num_files_hint="1000"
apc.user_entries_hint="4096"
apc.ttl="3600"
apc.user.ttl="3600"
apc.max_file_size="1M"
apc.gc_ttl="7200"
apc.stat="0"
-----------------



and here are my settings I have for xcache:
---------------------
[xcache-common]
zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20060613/xcache.so
auto_globals_jit = Off

[xcache.admin]
xcache.admin.user = "adm"
xcache.admin.pass = "pw"

[xcache]
xcache.shm_scheme = "mmap"
xcache.size = 96M
xcache.count = 1
xcache.slots = 4K
xcache.ttl = 3600
xcache.gc_interval = 300
xcache.readonly_protection = Off
xcache.mmap_path = "/dev/zero"
xcache.cacher = On

;var settings
xcache.var_size = 4M
xcache.var_count = 1
xcache.var_slots = 4K

;var ttl settings
xcache.var_ttl = 3600
xcache.var_maxttl = 7200
xcache.var_gc_interval = 300



It doesn't matter which one I use, they both clear out after a while and well before the ttl setting is reached. I think it has something to do with the number of processes in some way from what I read on the xcache website in the faq section.

NiteWave
06-18-2011, 04:48 AM
I think it has something to do with the number of processes in some way from what I read on the xcache website in the faq section
maybe you refer:
http://xcache.lighttpd.net/wiki/Faq#Whyismycachebeingcleared

then how many litespeed processes are running on your server?
#pstree -p | grep litespeed

what you observed is just the reason why on shared hosting environment, only eAccelerator is recommended. all php processes can share the opcode cache under a single disk folder, like /tmp/eaccelerator. usually, php suExec is enabled in such environment. APC and XCache only keep opcode cache in memory. so each group of php processes will have its own cache.

NUTNDUN
06-18-2011, 04:54 AM
Here is the output of the command you posted:

pstree -p | grep litespeed
|-litespeed(20208)-+-httpd(20209)
| `-litespeed(20210)-+-lsphp5(1343)---sh(5522)---convert(5523)


php suEXEC has been disabled since it was mentioned two days ago.

NiteWave
06-18-2011, 05:00 AM
ok, this suggest me might that reason ....
please post the lsphp5's setting:
Server -> External App -> lsphp5: View

NUTNDUN
06-18-2011, 05:08 AM
Here are the settings:

Name lsphp5

Address uds://tmp/lshttpd/lsphp5.sock

Notes Not Set

Max Connections 35

Environment
PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=35

Initial Request Timeout (secs) 60

Retry Timeout (secs) 0

Persistent Connection Yes

Connection Keepalive Timeout Not Set

Response Buffering No

Auto Start Yes

Command $SERVER_ROOT/fcgi-bin/lsphp5

Back Log 100

Instances 1

suEXEC User Not Set

suEXEC Group Not Set

Run On Start Up Not Set

Max Idle Time 10

Priority 0

Memory Soft Limit (bytes) 450M

Memory Hard Limit (bytes) 500M

Process Soft Limit 200

Process Hard Limit 200

NiteWave
06-18-2011, 05:10 AM
change "Max Idle Time" 10 to -1

NUTNDUN
06-18-2011, 05:18 AM
Ok, will try it and let you know how it goes.

NUTNDUN
06-18-2011, 06:17 AM
I thought for sure it was good to go because that was the longest it lasted without being reset. It got up to about 69,000 hits and then it cleared out again.

NiteWave
06-18-2011, 09:24 AM
pstree -p | grep litespeed
|-litespeed(20208)-+-httpd(20209)
| `-litespeed(20210)-+-lsphp5(1343)---sh(5522)---convert(5523)
APC or xcache is associated with a lsphp5 process(or a group of processes:a parent process, a few child processes). in example of above case, it's lsphp5 which pid=1343. if in some reason, this process is killed and a new lsphp5 process is started by its parent litespeed(in above example, pid=20210), then you'll notice opcode cache is cleared.

so monitor lsphp5's pid at the same time while monitoring the cache hits number. if the pid changes, the issue is turned to be how to keep it longer and what's reason it's killed and restarted again.

cmanns
06-21-2011, 11:31 PM
maybe you refer:
http://xcache.lighttpd.net/wiki/Faq#Whyismycachebeingcleared

then how many litespeed processes are running on your server?
#pstree -p | grep litespeed

what you observed is just the reason why on shared hosting environment, only eAccelerator is recommended. all php processes can share the opcode cache under a single disk folder, like /tmp/eaccelerator. usually, php suExec is enabled in such environment. APC and XCache only keep opcode cache in memory. so each group of php processes will have its own cache.

We've used Xcache for over 4 years with fastcgi. Over a year now with lsws

Set max requests to like 2k or so, set a few more instances. Set xcache to /dev/shm with 64mb mem

We get great performance in an env with dosenz of suexec php users. We get about 2-3 tops per vhost so they cache hit good. Also set childs lower and parents 2-4.

APC and EA suck. I've tried them on and off over the years, xcache gives us lowest php exec and low cpu usage.

NUTNDUN
06-22-2011, 03:52 PM
I agree xcache is much faster. I have been running eaccelerator for a little bit and it seemed to do the same reset but not as often. I just switched it back to xcache and the page loading is almost twice as fast.

If it only resets once an hour I can live with that. I will tweak the settings some more over the next couple of days and maybe even try some of the settings that you mentioned.

I did change these settings:

PHP_LSAPI_MAX_REQUESTS=1
PHP_LSAPI_CHILDREN=50

and I still have keep alive set to -1.

webizen
06-22-2011, 04:28 PM
It is better set PHP_LSAPI_MAX_REQUESTS=500 or 1000. You don't want a child php process just serves one request and exits. Max Idle time by default (not set) is -1 (server never kill the parent PHP process). Another possibility of opcode cache reset is server restart (by itself). You can verify the server uptime in realtime stats and see if it does restart often (uptime is short). if so, you need to check error.log around the time it restarts for clue.


...
I did change these settings:

PHP_LSAPI_MAX_REQUESTS=1
PHP_LSAPI_CHILDREN=50

and I still have keep alive set to -1.

NiteWave
06-22-2011, 06:54 PM
also, you change the default setting
PHP_LSAPI_CHILDREN=35
to
PHP_LSAPI_CHILDREN=50

then have you changed
Max Connections:35
as well? should change it to 50 as well. these 2 settings should match

NUTNDUN
06-23-2011, 04:09 PM
Ok, something is definitely restarting the litespeed server. Just have to figure out what and if anyone has any tips on how to go about that I am all ears. Here is what is in the info log from the litespeed admin panel after a recent reset.

2011-06-23 18:04:59.268 NOTICE Server Restart Request via Signal...
2011-06-23 18:04:59.269 NOTICE [PID: 13711]: start cgid: 7379, /usr/local/lsws/bin/lscgid
2011-06-23 18:04:59.269 NOTICE [Child: 13715] Start shutting down gracefully ...
2011-06-23 18:04:59.269 INFO Pass listener 127.0.0.1:443.
2011-06-23 18:04:59.269 INFO Pass listener 127.0.0.1:80.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.72:443.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.72:80.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.73:443.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.73:80.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.74:443.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.74:80.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.75:443.
2011-06-23 18:04:59.269 INFO Pass listener 173.199.147.75:80.
2011-06-23 18:04:59.269 INFO Pass listener *:7080.
2011-06-23 18:04:59.270 INFO Stop listener 127.0.0.1:443.
2011-06-23 18:04:59.270 INFO Stop listener 127.0.0.1:80.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.72:443.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.72:80.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.73:443.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.73:80.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.74:443.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.74:80.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.75:443.
2011-06-23 18:04:59.270 INFO Stop listener 173.199.147.75:80.
2011-06-23 18:04:59.270 INFO Stop listener *:7080.
2011-06-23 18:04:59.513 NOTICE Your License key will expire in 14 days
2011-06-23 18:04:59.513 NOTICE Loading LiteSpeed/4.1.1 Enterprise ...
2011-06-23 18:04:59.715 NOTICE [ADMIN] server socket: uds://usr/local/lsws/admin/tmp/admin.sock.7689
2011-06-23 18:04:59.715 NOTICE Loading configuration from /usr/local/lsws/conf/httpd_config.xml ...
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [127.0.0.1:443]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [127.0.0.1:80]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.72:443]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.72:80]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.73:443]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.73:80]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.74:443]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.74:80]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.75:443]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [173.199.147.75:80]
2011-06-23 18:04:59.716 NOTICE Recovering server socket: [*:7080]
2011-06-23 18:04:59.716 NOTICE [config] chroot is disabled.
2011-06-23 18:04:59.716 INFO old priority: -19, new priority: -19
2011-06-23 18:04:59.716 INFO [config:server:basic] For better obscurity, server version number is hidden in the response header.
2011-06-23 18:04:59.737 NOTICE [PID: 7404]: start cgid: 7407, /usr/local/lsws/bin/httpd
2011-06-23 18:04:59.737 WARN [config:server:listener] No listener is available for normal virtual host!
2011-06-23 18:04:59.737 NOTICE The maximum number of file descriptor limit is set to 6000.
2011-06-23 18:04:59.738 NOTICE [config] Cache function requires a 2-CPU license or above.
2011-06-23 18:04:59.738 INFO Processing config file: /usr/local/apache/conf/includes/pre_main_global.conf
2011-06-23 18:04:59.738 INFO Processing config file: /usr/local/apache/conf/includes/pre_main_2.conf
2011-06-23 18:04:59.738 INFO Processing config file: /usr/local/apache/conf/php.conf
2011-06-23 18:04:59.738 INFO Processing config file: /usr/local/apache/conf/includes/errordocument.conf
2011-06-23 18:04:59.738 INFO Processing config file: /usr/local/apache/conf/modsec2.conf
2011-06-23 18:04:59.746 INFO Processing config file: /usr/local/apache/conf/modsec2.user.conf
2011-06-23 18:04:59.750 INFO Processing config file: /usr/local/apache/conf/includes/pre_virtualhost_global.conf
2011-06-23 18:04:59.750 INFO Processing config file: /usr/local/apache/conf/includes/pre_virtualhost_global.conf
2011-06-23 18:04:59.750 INFO Processing config file: /usr/local/apache/conf/includes/pre_virtualhost_2.conf
2011-06-23 18:04:59.750 INFO Processing config file: /usr/local/apache/conf/includes/pre_virtualhost_2.conf
2011-06-23 18:04:59.751 INFO Processing config file: /usr/local/apache/conf/includes/post_virtualhost_global.conf
2011-06-23 18:04:59.751 INFO Processing config file: /usr/local/apache/conf/includes/post_virtualhost_global.conf
2011-06-23 18:04:59.751 INFO Processing config file: /usr/local/apache/conf/includes/post_virtualhost_2.conf
2011-06-23 18:04:59.751 INFO Processing config file: /usr/local/apache/conf/includes/post_virtualhost_2.conf
2011-06-23 18:04:59.756 NOTICE litespeed (7404) is ready
2011-06-23 18:04:59.757 NOTICE [child: 7409] Successfully change current user to nobody
2011-06-23 18:04:59.757 NOTICE [Child: 7409] Core dump is enabled.
2011-06-23 18:04:59.757 NOTICE [Child: 7409] Setup swapping space...
2011-06-23 18:04:59.757 NOTICE [Child: 7409] LiteSpeed/4.1.1 Enterprise starts successfully!
2011-06-23 18:04:59.757 NOTICE [AutoRestarter] new child process with pid=7409 is forked!
2011-06-23 18:04:59.770 NOTICE New litespeed process is ready, litespeed (13715) stops listeners
2011-06-23 18:04:59.770 INFO Stop listener 127.0.0.1:443.
2011-06-23 18:04:59.770 INFO Stop listener 127.0.0.1:80.
2011-06-23 18:04:59.770 INFO Stop listener 173.199.147.72:443.
2011-06-23 18:04:59.771 INFO Stop listener 173.199.147.72:80.
2011-06-23 18:04:59.771 INFO Stop listener 173.199.147.73:443.
2011-06-23 18:04:59.771 INFO Stop listener 173.199.147.73:80.
2011-06-23 18:04:59.771 INFO Stop listener 173.199.147.74:443.
2011-06-23 18:04:59.771 INFO Stop listener 173.199.147.74:80.
2011-06-23 18:04:59.771 INFO Stop listener 173.199.147.75:443.
2011-06-23 18:04:59.771 INFO Stop listener 173.199.147.75:80.
2011-06-23 18:04:59.771 INFO Stop listener *:7080.
2011-06-23 18:04:59.771 NOTICE [Child: 13715] Shut down successfully!
2011-06-23 18:04:59.771 NOTICE [lsphp5] stop worker processes
2011-06-23 18:04:59.774 NOTICE [AutoRestarter] cleanup children processes and unix sockets of process with pid=13715 !
2011-06-23 18:04:59.774 INFO [CLEANUP] Clean up child process with pid: 13887
2011-06-23 18:04:59.874 NOTICE [AutoRestarter] child process with pid=13715 exited with status=0!
2011-06-23 18:04:59.875 NOTICE [PID:13711] Server Stopped!
2011-06-23 18:05:00.105 NOTICE [AutoUpdate] Checking for new releases..., pid=7412
2011-06-23 18:05:00.115 NOTICE Start to clean up cache directory, pid=7413
2011-06-23 18:05:00.211 INFO [AutoUpdate] No new update.
2011-06-23 18:05:00.310 INFO [HTAccess] Updating configuration from [/home/gttnut/public_html/.htaccess]
2011-06-23 18:05:01.076 INFO [127.0.0.1:47606-0#APVH_*_sv1.gttalk.com] File not found [/usr/local/apache/htdocs/whm-server-status]
2011-06-23 18:05:01.078 INFO [LICENSE] License is OK.
2011-06-23 18:05:01.091 INFO [127.0.0.1:47607-0#APVH_*_sv1.gttalk.com] File not found [/usr/local/apache/htdocs/server-status]
2011-06-23 18:05:11.808 INFO [HTAccess] Updating configuration from [/home/gttalk/public_html/.htaccess]
2011-06-23 18:06:15.361 INFO [HTAccess] Updating configuration from [/home/opt/public_html/.htaccess]

NUTNDUN
06-23-2011, 04:16 PM
Here are my current configuration settings also:

General:
----------------------------------------------
Server Name $HOSTNAME
Running As user(nobody) : group(nobody)
Priority -19
chroot Path /
Enable chroot No
Enable LVE Not Set
Memory I/O Buffer 60M
Swapping Directory /tmp/lshttpd/swap
Auto Restart Yes
Auto Fix 503 Error Yes
Graceful Restart Timeout (secs) Not Set
MIME Settings $SERVER_ROOT/conf/mime.properties
Disable Initial Log Rotation Yes
Server Signature Hide Version
Enable IP GeoLocation Not Set
Use Client IP in Header Not Set
Check For Update Daily
Download Updates Yes
Administrator Email root@localhost
Index Files index.html, index.php, index.php5, index.htm
Auto Index No
Auto Index URI Not Set
HT Access Edit
Allow Override Limit Auth FileInfo Indexes Options None
Access File Name .htaccess
Enable Expires Yes
Expires Default Not Set
Expires By Type image/*=A604800, text/css=A604800, application/x-javascript=A604800, application/javascript=A604800
IP to GeoLocation DB Add DB File Path DB Cache Type Action
Load Apache Configuration Yes
Auto Reload On Changes Use Apache binary wrapper
Apache Binary Path /usr/local/apache/bin/httpd
Apache Configuration File /usr/local/apache/conf/httpd.conf
Apache Port Offset 0
Apache IP Offset 0
Apache Handled Content Not Set
Ignore Apache Modules Not Set
PHP suEXEC No
PHP suEXEC Max Conn 10
Enable FrontPage Extension No
Apache Style Configurations Edit
Apache Style configurations Not Set



Here are a LSPHP5 settings:
-------------------------------------------
Name lsphp5
Address uds://tmp/lshttpd/lsphp5.sock
Notes Not Set
Max Connections 50
Environment PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=50
Initial Request Timeout (secs) 60
Retry Timeout (secs) 0
Persistent Connection Yes
Connection Keepalive Timeout -1
Response Buffering No
Auto Start Yes
Command $SERVER_ROOT/fcgi-bin/lsphp5
Back Log 100
Instances 1
suEXEC User Not Set
suEXEC Group Not Set
Run On Start Up Not Set
Max Idle Time -1
Priority 0
Memory Soft Limit (bytes) 450M
Memory Hard Limit (bytes) 500M
Process Soft Limit 200
Process Hard Limit 200

NiteWave
06-23-2011, 06:18 PM
does it happen often?

NUTNDUN
06-23-2011, 06:23 PM
Seems to be averaging about once an hour or so, it isn't consistent either, like one time it might be 45 minutes and then the next time it might be an hour and 15 minutes. So far the highest hits I have been able to get on xcache has been 195,000 and that lasted about an hour and fifteen minutes.

We do have configserver plugin installed on this one but we also had it on our last vps. Clam AV is also on it and we didn't have it on the other server.

NiteWave
06-23-2011, 07:10 PM
so the issue is: lsws restarts about once 1 hour in unknown reason, and that can explain the cache reset issue. true?

NUTNDUN
06-24-2011, 01:46 AM
Yes that seems to be the issue.

webizen
06-24-2011, 09:53 AM
Did you get email from cPanel when LSWS was restarted?

Yes that seems to be the issue.

NUTNDUN
06-24-2011, 10:18 AM
No, I am not getting any emails about LSWS being restarted. I get emails if I goof up trying to login the the LSWS admin panel though.

cmanns
06-24-2011, 06:16 PM
so the issue is: lsws restarts about once 1 hour in unknown reason, and that can explain the cache reset issue. true?

I'm running 4.1.1 and it exists every hour or so too without reason.


Anyways guy try this

We got child procs to 4 (half of cpu's, we have muti-client using php so we dont want them overtaking all cpus by 1 proc on accident randomly)

max req per proc on php is 2500, 5000 caused one proc to do 90% cpu roughly on some clock strace I thought I posted the error here but seems I forgot (was tired, sorry nitewave

2000/2500 seems nice. XCache caches decent, php process idle time is 120 seconds so it's hopefully one of the 4 possibly spawned per 20 or so vhosts is active. Ram seems okay barely swap on a 10gb system with high mem tuned mysql with 16gb of db's

priestjim
11-18-2011, 04:30 AM
I've been experiencing cache clearing as well. I have configured Litespeed to let PHP/LSAPI to self-manage its instances:

Instances: 1
Suexec: on
Max connections: 64
PHP_LSAPI_CHILDREN=64
LSAPI_CHILDREN=64

From my experience with PHP-FPM (where opcode caches work perfectly) the process tree in litespeed should work as:
- lshttpd
-- lsphp5 process manager
--- lsphp5 (as user example1 - child process)
--- lsphp5 (as user example1 - child process)
--- lsphp5 (as user example2 - child process)
--- lsphp5 (as user example2 - child process)

where the lsphp5 process manager spawns lsphp5 processes running as suexec user example1 and example2 depending on the requests served and each one of them can read/write the process manager's shared memory segment that caches both example1 and example2 user files.

What I get on Litespeed is no lsphp5 process manager and many example1 processed that each one of them run their own mmap cache segment which in turn constitutes any opcode cache useless.

We *need* an operational opcode cache mechanism on Litespeed! Please fix it!

NiteWave
11-18-2011, 06:00 AM
I have configured Litespeed to let PHP/LSAPI to self-manage its instances
since you set
Suexec: on

lsphp is not in self-manage mode.

any opcode cache useless.
when php suExec enabled, only eAccelerator able to share opcode cache between processes, since the opcode cache is saved on disk.

priestjim
11-18-2011, 06:16 AM
This should be then a feature request then, since with suexec disabled PHP is pretty much useless in a shared environment.

FYI, nginx + php-fpm operates EXACTLY as fastcgi + opcode cache should.

mistwang
11-18-2011, 01:50 PM
that feature is on our to-do list. no ETA yet.

prandah
11-23-2011, 02:06 AM
hello, how to know
xcache, apc, eacelarator is actif ?
any advice ?

webizen
11-23-2011, 10:14 AM
hello, how to know
xcache, apc, eacelarator is actif ?
any advice ?

1. create a phpinfo page like


echo "<?php phpinfo(); ?>" > /path/to/file/named/phpinfo.php


then point browser to that file and see if you have these listed.

or

2. run command line


/usr/local/lsws/fcgi-bin/lsphp5 -i | egrep -i 'apc|xcache|eaccelarator'


if nothing comes up, then none of them is compiled in lsphp.

prandah
11-23-2011, 10:56 AM
hello thanks for reply :D


[root@poseidon ~]# /usr/local/lsws/fcgi-bin/lsphp5 -i | egrep -i 'apc|xcache|eaccelarator'
Configure Command => './configure' '--prefix=/usr/local/lsws/lsphp5' '--with-mysqli' '--with-gd' '--enable-shmop' '--enable-track-vars' '--enable-sockets' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--with-litespeed' '--with-zlib' '--with-mysql' '--with-curl' '--with-config-file-path=/opt/lsws/php5' '--with-ioncube' '--with-pic' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--with-gettext' '--with-jpeg-dir=/usr' '--with-png' '--with-xcache' '--enable-xcache' '--with-php-config=/usr/local/lsws/lsphp5/bin/php-config' '--enable-suhosin'
[root@poseidon ~]#


what a command to compile it ?

webizen
11-23-2011, 11:21 AM
They are not part of php source so you can NOT do --enable or --with to compile them. Refer to their own document for compile/install with php.

eAccelerator: https://eaccelerator.net/wiki/InstallFromSource
APC: http://www.php.net/manual/en/apc.installation.php
xCache: http://xcache.lighttpd.net/wiki/InstallFromSource

prandah
11-23-2011, 01:03 PM
hello thanks for your reply
there is true ?


[root@pegasus php]# /usr/local/lsws/fcgi-bin/lsphp5 -i | egrep -i 'apc|xcache|eaccelarator'
with XCache v1.3.1, Copyright (c) 2005-2010, by mOo
XCache
XCache Support => enabled
xcache.admin.enable_auth => On => On
xcache.cacher => On => On
xcache.coredump_directory => no value => no value
xcache.count => 1 => 1
xcache.gc_interval => 0 => 0
xcache.mmap_path => /dev/zero => /dev/zero
xcache.readonly_protection => 0 => 0
xcache.shm_scheme => mmap => mmap
xcache.size => 0 => 0
xcache.slots => 8K => 8K
xcache.stat => On => On
xcache.test => 0 => 0
xcache.ttl => 0 => 0
xcache.var_count => 1 => 1
xcache.var_gc_interval => 120 => 120
xcache.var_maxttl => 0 => 0
xcache.var_size => 0 => 0
xcache.var_slots => 8K => 8K
xcache.var_ttl => 0 => 0
[root@pegasus php]#

webizen
11-23-2011, 01:24 PM
this means xcache is enabled.

prandah
11-24-2011, 12:36 AM
hello webizen
i have little confuse


[root@poseidon php]# /usr/local/lsws/fcgi-bin/lsphp5 -i | egrep -i 'apc|xcache|eaccelarator'
with XCache v1.3.2, Copyright (c) 2005-2011, by mOo
XCache
XCache Support => enabled
xcache.admin.enable_auth => On => On
xcache.cacher => On => On
xcache.coredump_directory => no value => no value
xcache.count => 1 => 1
xcache.gc_interval => 0 => 0
xcache.mmap_path => /dev/zero => /dev/zero
xcache.readonly_protection => 0 => 0
xcache.shm_scheme => mmap => mmap
xcache.size => 0 => 0
xcache.slots => 8K => 8K
xcache.stat => On => On
xcache.test => 0 => 0
xcache.ttl => 0 => 0
xcache.var_count => 1 => 1
xcache.var_gc_interval => 120 => 120
xcache.var_maxttl => 0 => 0
xcache.var_size => 0 => 0
xcache.var_slots => 8K => 8K
xcache.var_ttl => 0 => 0


xcached enable

but when i check

[root@poseidon lsws]# fcgi-bin/lsphp5 -v
PHP 5.2.17 (litespeed) (built: Nov 23 2011 17:33:56)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
[root@poseidon lsws]#

webizen
11-25-2011, 06:06 PM
I have to take it back.

you need to be in /usr/local/lsws/fcgi-bin/ to check lsphp5.

for below, it is likely you are in a different directory (.../php) that has a copy of php.ini with "extension=xcache.so" in it.


[root@poseidon php]# /usr/local/lsws/fcgi-bin/lsphp5 -i | egrep -i 'apc|xcache|eaccelarator'
with XCache v1.3.2, Copyright (c) 2005-2011, by mOo
...


However, your fcgi-bin/lsphp5 uses a copy of php.ini with *NO* "extension=xcache.so" (xcache not enabled). that's why 'fcgi-bin/lsphp5 -v' shows no xcache. To find out which php.ini your lsphp5 uses, do following.

/usr/local/lsws/fcgi-bin/lsphp5 -i| grep php.ini


So in your case, lsphp5 doesn't not have xcache enabled.

prandah
11-25-2011, 10:36 PM
yes i have copy it to /opt/
thanks webizen
my problem solved now :D

prandah
11-27-2011, 03:16 AM
hello
i have install it
but i still confused


HTTP/1.0 200 OK

X-Powered-By: PHP/5.2.17

Cache-Control: private

Pragma: private

Content-Type: text/html; charset=ISO-8859-1

X-UA-Compatible: IE=7

Content-Encoding: gzip

Content-Length: 19414
Date: Sun, 27 Nov 2011 10:15:05 GMT

Server: LiteSpeed

X-Cache: MISS from wire.clearos.lan

X-Cache-Lookup: MISS from wire.clearos.lan:3128

Via: 1.0 wire.clearos.lan:3128 (squid/2.6.STABLE21)

Connection: keep-alive


how to know xcache work ?

webizen
11-28-2011, 11:20 AM
you may install an xcache admin page to look at details.

http://xcache.lighttpd.net/wiki/InstallAdministration

prandah
11-28-2011, 11:33 AM
wow work like charm :D
thanks webizen

azn_romeo_4u
12-21-2011, 09:18 PM
I'm having problems. I used the build php with xcache and memcached check in the lsws admin page. I noted down the install directory for xcache.so

When I check php -v it says xcache is installed. But when I view a phpinfo on a web page no xcache is installed.


zend_extension = "/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/xcache.so"
[xcache.admin]
xcache.admin.auth = off
xcache.admin.enable_auth = off
xcache.admin.user = "test"
xcache.admin.pass = "098f6bcd4621d373cade4e832627b4f6"
;xcache.admin.pass = "53f018f2ee1fc4fb7ad2be1cc7b9ed43"
[xcache]
xcache.shm_scheme = "mmap"
xcache.size = 256M
xcache.cacher="On"
xcache.coredump_directory=""
xcache.count="8"
;xcache.coveragedump_directory="/tmp/pcov/"
xcache.optimizer="Off"
xcache.readonly_protection="Off"
xcache.test="Off"
xcache.slots="8K"
xcache.readonly_protection = Off
xcache.ttl="3600"
xcache.gc_interval = 300
xcache.var_size = 4M
xcache.var_count = 8
xcache.var_slots = 1K
; default ttl
xcache.var_ttl = 3600
xcache.var_maxttl = 7200
xcache.var_gc_interval = 300

NiteWave
12-21-2011, 10:28 PM
But when I view a phpinfo on a web page no xcache is installed.
does this file exist?
/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20060613/xcache.so

prandah
12-22-2011, 01:08 PM
When I check php -v it says xcache is installed. But when I view a phpinfo on a web page no xcache is installed.

if you check from php -v i think it's wrong
try fcgi-bin/lsphp5 -v

if you check with php -v alsi it just chect your server
and not your litespeed CMIIW

example :


[root@xxxx lsws]# fcgi-bin/lsphp5 -v
PHP 5.2.17 (litespeed) (built: Nov 23 2011 17:33:56)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with XCache v1.3.2, Copyright (c) 2005-2011, by mOo
with the ionCube PHP Loader v4.0.11, Copyright (c) 2002-2011, by ionCube Ltd., and
with Zend Extension Manager v1.2.0, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.2.8, Copyright (c) 1998-2007, by Zend Technologies
[root@xxxx lsws]#

semprot
05-08-2012, 07:36 PM
maybe you refer:
http://xcache.lighttpd.net/wiki/Faq#Whyismycachebeingcleared

then how many litespeed processes are running on your server?
#pstree -p | grep litespeed

what you observed is just the reason why on shared hosting environment, only eAccelerator is recommended. all php processes can share the opcode cache under a single disk folder, like /tmp/eaccelerator. usually, php suExec is enabled in such environment. APC and XCache only keep opcode cache in memory. so each group of php processes will have its own cache.
Here it is (while i open litespeed admin on whm)

root@mybox [~]# pstree -p | grep litespeed
|-litespeed(28249)-+-httpd(28250)
| |-litespeed(28251)-+-admin_php(32375)
| | |-{litespeed}(28253)
| | `-{litespeed}(28254)
| `-litespeed(28252)-+-lsphp5(28271)-+-lsphp5(32446)
| |-{litespeed}(28255)
| `-{litespeed}(28256)


ok, this suggest me might that reason ....
please post the lsphp5's setting:
Server -> External App -> lsphp5: ViewHere it is
Name : lsphp5
Address : uds://tmp/lshttpd/lsphp5.sock
Notes : Not Set
Max Connections : 35

Environment :
PHP_LSAPI_MAX_REQUESTS=500
PHP_LSAPI_CHILDREN=35
Initial Request Timeout (secs) : 60
Retry Timeout (secs) : 0
Persistent Connection : Yes
Connection Keepalive Timeout : Not Set
Response Buffering : No
Auto Start : Yes
Command : $SERVER_ROOT/fcgi-bin/lsphp5
Back Log : 100
Instances : 1
suEXEC User : Not Set
suEXEC Group : Not Set
Run On Start Up : Not Set
Max Idle Time : 10
Priority : 0
Memory Soft Limit (bytes) : 1024M
Memory Hard Limit (bytes) : 1024M
Process Soft Limit : 500
Process Hard Limit : 500

What setting should i change? Max idle time to -1?

NiteWave
05-08-2012, 07:59 PM
Max idle time to -1?
it will help. what's your issue? "Trying to use APC but it seems to be clearing out" as titled ?

semprot
05-08-2012, 08:07 PM
it will help. what's your issue? "Trying to use APC but it seems to be clearing out" as titled ?Yes.. My APC is restarted every 30mins-3 hours, (more frequent at peak traffic).

NiteWave
05-08-2012, 08:20 PM
please watch the result after set "Max idle time" -1

semprot
05-08-2012, 10:29 PM
please watch the result after set "Max idle time" -1i've set it to -1 about 1 h ago, but my apc was restarted 20 minutes ago.. Any log that i should check?

NiteWave
05-09-2012, 07:45 PM
my apc was restarted 20 minutes ago..
please memo down the pid of parent lsphp5, see if it changes too.
in your previous post,
litespeed(28252)-+-lsphp5(28271)-+-lsphp5(32446)
parent lsphp5 pid is 28271

semprot
05-09-2012, 07:58 PM
please memo down the pid of parent lsphp5, see if it changes too.
in your previous post,

parent lsphp5 pid is 28271Here is my result now

root@mybox[~]# pstree -p | grep litespeed
|-litespeed(10551)-+-httpd(10552)
| |-litespeed(10553)-+-lsphp5(10559)-+-lsphp5(14546)
| | |-{litespeed}(10555)
| | `-{litespeed}(10556)
| `-litespeed(10554)-+-lsphp5(10595)-+-lsphp5(13525)
| |-{litespeed}(10557)
| `-{litespeed}(10558)

Yes it is changed now, so it seems litespeed was restarted?

NiteWave
05-09-2012, 08:06 PM
yes, if pid of litespeed changed, it must have been restarted.

litespeed may restart to fix 503 error automatically.
in a site with buggy php script, this may be helpful without whole site down.

semprot
05-09-2012, 08:16 PM
yes, if pid of litespeed changed, it must have been restarted.

litespeed may restart to fix 503 error automatically.
in a site with buggy php script, this may be helpful without whole site down.Usually when i got an 503 error and LS was restarted, i got an e-mail notification. Why i didn't get any notification?

Is there any log that i can check to see why it happened?
I tried to open "Server Log Viewer" but there are too many.

NiteWave
05-09-2012, 08:44 PM
grep "Server Stopped" in error log, check log entries before it.

TarkanVeKurdu
08-16-2012, 12:21 PM
that feature is on our to-do list. no ETA yet.

Hello,

Is there any progress on this feature? We really need to have this feature while suphp enabled on the shared hosting environments.

Regards

webizen
08-17-2012, 11:18 AM
Hello,

Is there any progress on this feature? We really need to have this feature while suphp enabled on the shared hosting environments.

Regards

This is being tested and will be out soon.

semprot
08-23-2012, 10:27 AM
my apc is clearing out again even my litespeed is not restarted (i compared the apc uptime & litespeed uptime). apc uptime is about 6 mins, while the lsws uptime is about 30 mins now.

It started to happen after my physical server restart. It was fine before.

my memory usage is low.. about 12 percent.

any idea what to check? :confused:

webizen
08-23-2012, 11:39 AM
if you have PHP suEXEC (http://www.litespeedtech.com/docs/webserver/config/general/#phpSuExec) enabled (for shared hosting), APC uptime will be like this.

semprot
08-24-2012, 10:05 AM
if you have PHP suEXEC (http://www.litespeedtech.com/docs/webserver/config/general/#phpSuExec) enabled (for shared hosting), APC uptime will be like this.It is disabled and i use dedicated server.
Litespeed uptime is very good (1 day+ -- since previous restart).
But APC uptime is 36 mins or so.

Any idea?

Runtime Settings
apc.cache_by_default 1
apc.canonicalize 1
apc.coredump_unmap 0
apc.enable_cli 1
apc.enabled 1
apc.file_md5 0
apc.file_update_protection 2
apc.filters
apc.gc_ttl 3600
apc.include_once_override 0
apc.lazy_classes 0
apc.lazy_functions 0
apc.max_file_size 20M
apc.mmap_file_mask /tmp/apc.nyEjzk
apc.num_files_hint 1000
apc.preload_path
apc.report_autofilter 0
apc.rfc1867 0
apc.rfc1867_freq 0
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.rfc1867_ttl 3600
apc.serializer default
apc.shm_segments 1
apc.shm_size 1024M
apc.slam_defense 1
apc.stat 0
apc.stat_ctime 0
apc.ttl 0
apc.use_request_time 1
apc.user_entries_hint 4096
apc.user_ttl 7200
apc.write_lock 1

Thanks.

Addition : i got this tips on stackoverflow :
"How many Litespeed processes do you have? I'm afraid that if you have more than 1 process, you'll have the same problem as with fastcgi/suphp, so you should try to recompile APC with --disable-apc-mmap".

How to know how many litespeed process that i have? i use 2 cpu license.
root@mybox [~]# pstree -p | grep litespeed
|-litespeed(19722)-+-httpd(19723)
| |-litespeed(19724)-+-lsphp5(19730)-+-lsphp5(19734)
| | |-{litespeed}(19726)
| | `-{litespeed}(19728)
| `-litespeed(19725)-+-lsphp5(19772)-+-lsphp5(19809)
| |-{litespeed}(19727)
| `-{litespeed}(19729)

webizen
08-24-2012, 02:04 PM
for 2-cpu license, you have effectively two litespeed processes (1 parent pid 19722 and 2 active: pid 19724 and 19725 in your case).

whatsup
08-25-2012, 03:25 PM
Been reading different treads about this. Just upgraded to Litespeed 1 CPU version one month ago. I am now testing out Nginx also to see if I can get it to our server to work properly with APC.

webizen
08-31-2012, 05:40 PM
It is disabled and i use dedicated server.
Litespeed uptime is very good (1 day+ -- since previous restart).
But APC uptime is 36 mins or so.

Any idea?

Runtime Settings
apc.cache_by_default 1
apc.canonicalize 1
apc.coredump_unmap 0
apc.enable_cli 1
apc.enabled 1
apc.file_md5 0
apc.file_update_protection 2
apc.filters
apc.gc_ttl 3600
apc.include_once_override 0
apc.lazy_classes 0
apc.lazy_functions 0
apc.max_file_size 20M
apc.mmap_file_mask /tmp/apc.nyEjzk
apc.num_files_hint 1000
apc.preload_path
apc.report_autofilter 0
apc.rfc1867 0
apc.rfc1867_freq 0
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.rfc1867_ttl 3600
apc.serializer default
apc.shm_segments 1
apc.shm_size 1024M
apc.slam_defense 1
apc.stat 0
apc.stat_ctime 0
apc.ttl 0
apc.use_request_time 1
apc.user_entries_hint 4096
apc.user_ttl 7200
apc.write_lock 1

Thanks.

Addition : i got this tips on stackoverflow :
"How many Litespeed processes do you have? I'm afraid that if you have more than 1 process, you'll have the same problem as with fastcgi/suphp, so you should try to recompile APC with --disable-apc-mmap".

How to know how many litespeed process that i have? i use 2 cpu license.
root@mybox [~]# pstree -p | grep litespeed
|-litespeed(19722)-+-httpd(19723)
| |-litespeed(19724)-+-lsphp5(19730)-+-lsphp5(19734)
| | |-{litespeed}(19726)
| | `-{litespeed}(19728)
| `-litespeed(19725)-+-lsphp5(19772)-+-lsphp5(19809)
| |-{litespeed}(19727)
| `-{litespeed}(19729)


Our lab test shows '--disable-apc-mmap' makes no difference.

semprot
09-01-2012, 08:00 PM
Our lab test shows '--disable-apc-mmap' makes no difference.Somehow my issue was fixed, but it appears again now.

The issue is still the same :
- litespeed uptime is good, but
- apc uptime is bad :(

Any idea how to fix it?

NiteWave
09-01-2012, 08:38 PM
- litespeed uptime is good, but
- apc uptime is bad

if you refresh the apc stats page repeatly,
check the apc.mmap_file_mask value, like /tmp/apc.nyEjzk,
you should see 2 different files, corresponding 2 groups of lsphp5.

semprot
09-01-2012, 08:49 PM
- litespeed uptime is good, but
- apc uptime is bad

if you refresh the apc stats page repeatly,
check the apc.mmap_file_mask value, like /tmp/apc.nyEjzk,
you should see 2 different files, corresponding 2 groups of lsphp5.I see no "apc.mmap_file_mask" on my stats page. I think because my APC was compiled with "--disable-apc-mmap".
Should i recompile APC with mmap?
(as far as i remember, when my APC had mmap, i only saw 1 apc.mmap_file_mask value on stats page)

If not, what should i do?

NiteWave
09-01-2012, 11:24 PM
Should i recompile APC with mmap?
yes, please. we study the option -disable-apc-mmap in 2 ways:
1.by reading the APC source code
2.actual tests

as we pointed out in previous thread: it not working at all.
--enable-apc-mmap is enabled by default since APC 3.0.18.
so it's a better method than --disable-apc-mmap which is default before 3.0.18

i only saw 1 apc.mmap_file_mask value on stats page
please refresh repeatedly, it should have 2 values if you have 2 groups of lsphp5
root@mybox [~]# pstree -p | grep litespeed
|-litespeed(19722)-+-httpd(19723)
| |-litespeed(19724)-+-lsphp5(19730)-+-lsphp5(19734)
| | |-{litespeed}(19726)
| | `-{litespeed}(19728)
| `-litespeed(19725)-+-lsphp5(19772)-+-lsphp5(19809)
| |-{litespeed}(19727)
| `-{litespeed}(19729)

one group is lsphp5(19730), another one is lsphp5(19772)

semprot
09-02-2012, 12:08 AM
yes, please. we study the option -disable-apc-mmap in 2 ways:
1.by reading the APC source code
2.actual tests

as we pointed out in previous thread: it not working at all.
--enable-apc-mmap is enabled by default since APC 3.0.18.
so it's a better method than --disable-apc-mmap which is default before 3.0.18


please refresh repeatedly, it should have 2 values if you have 2 groups of lsphp5


one group is lsphp5(19730), another one is lsphp5(19772)I have recompiled APC with mmap enabled.

But i still see 1 value. Is it the cause of my problem?

FYI i have LSAPI_AVOID_FORK=1 , i don't know whether it is related with 1 mmap or not.root@mybox [~]# pstree -p | grep litespeed
|-litespeed(24846)-+-httpd(24847)
| |-litespeed(24848)-+-lsphp5(24856)-+-lsphp5(24857)
| | |-{litespeed}(24850)
| | `-{litespeed}(24851)
| `-litespeed(24849)-+-lsphp5(24901)-+-lsphp5(24904)
| |-{litespeed}(24852)
| `-{litespeed}(24853)
apc.cache_by_default 1
apc.canonicalize 1
apc.coredump_unmap 0
apc.enable_cli 1
apc.enabled 1
apc.file_md5 0
apc.file_update_protection 2
apc.filters
apc.gc_ttl 3600
apc.include_once_override 0
apc.lazy_classes 0
apc.lazy_functions 0
apc.max_file_size 20M
apc.mmap_file_mask /tmp/apc.3iYCNd
apc.num_files_hint 1000
apc.preload_path
apc.report_autofilter 0
apc.rfc1867 0
apc.rfc1867_freq 0
apc.rfc1867_name APC_UPLOAD_PROGRESS
apc.rfc1867_prefix upload_
apc.rfc1867_ttl 3600
apc.serializer default
apc.shm_segments 1
apc.shm_size 1024M
apc.slam_defense 1
apc.stat 0
apc.stat_ctime 0
apc.ttl 0
apc.use_request_time 1
apc.user_entries_hint 4096
apc.user_ttl 7200
apc.write_lock 1

NiteWave
09-02-2012, 08:25 PM
But i still see 1 value. Is it the cause of my problem?
should not be possible.

maybe your site's traffic is idle ? if so, you can generate some traffic and test again. also, you can create a script to access apc.php for 100 or 1000 times, grep "Uptime" and "apc.mmap_file_mask" every time, should be able to see 2 values.