Hello,
I hoep this is not a real noob question so really hope someone can help.
I installed the openlisespeed image on Google Cloud from the Marketplace.
One thing I cannot get to work is memcache. It shows it is enabled but "connection failed"
Host: localhost
(also tried 127.0.0.1 and /var/www/memcached.sock)
Port: 11211
Running Started memcached daemon I noticed something that might cause it, not sure:
Feb 05 16:23:07 vm systemd[1]: Started memcached daemon.
Feb 05 16:23:07 vm systemd-memcached-wrapper[661]: Could not open the pid file /var/r>
lines 1-12/12 (END)...skipping...
● memcached.service - memcached daemon
Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-02-05 16:23:07 UTC; 17h ago
Docs: man:memcached(1)
Main PID: 661 (memcached)
Tasks: 10 (limit: 8939)
Memory: 38.2M
CGroup: /system.slice/memcached.service
└─661 /usr/bin/memcached -m 64 -p 11211 -u www-data -l 127.0.0.1 -P /var/run/memcached/memcached.pid -s /var/www/memcached.sock -a 0770 -p /tmp/memcached.pid
Feb 05 16:23:07 lvm systemd[1]: Started memcached daemon.
Feb 05 16:23:07 vm systemd-memcached-wrapper[661]: Could not open the pid file /var/run/memcached/memcached.pid.tmp for writing: Permission denied
Running: ss -lptun | grep 11211
No result, just a next line so no response at all.
Running: telnet localhost 11211
vm:~# telnet localhost 11211
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
Please let me know if I am missing something or how to I can fix this.
Thank you in advance!
The GCloud deployment has memcached set up in an Unix Socket. In order for it to work with the LSCache plugin you have to use localhost as the specified directory and 0 as the port (the idea of the UNIX socket is to avoid routing thus ports don't matter)
Regarding the PID file error, it is because of weird Ubuntu/Memcached permission issues in the specified PID folder. Even I was unable to change it with root access and chown-ing the folder with any user/group or access level, it just kept reverting the permissions of that directory. A workaround is to remove the -P line in the memcached.conf file. (removing the line had no effect on a test server I used)
The bug has been around since 2013:
Forum post describing the issue a bit
Locate memcached.conf
default path should be /etc/memcached.conf
the .conf file should have the following:
-u www-data (should be the same user as lsphp)
-s /var/www/memcached.sock (this is the UNIX socket)
-a 0770 (this is the permission level)
-p /tmp/memcached.pid (this is the temp PID location)
-P /var/run/memcached/memcached.pid
the last line is the problematic bit you see in the memcached status, it basically tells memcached where to put the PID file but as described in the link above, it messes up permissions and results in a fail but the PID file was already created so either delete this to remove the error message or just ignore it as memcached should work as intended regardless.
Bonus for memcached config:
While we are at it, a great way of optimizing memcached is to use igbinary serializer, it will greatly help reduce the memory footprint of memcached and will work wonders on small servers coupled with the UNIX socket.
In order to do that, locate the memcached.ini using the following command:
open the .ini and replace the line SERIALIZER_PHP with SERIALIZER_IGBINARY
Please note that you would need the igbinary PECL extension and memcached with igbinary support (add --enable-memcached-igbinary during memcached installation) (both are done by default for you using the GCloud deployment of OLS)
after doing so you would have to flush the old cache:
Code:
nc -U /var/www/memcached.sock
flush_all
quit
or
Code:
echo "flush_all" | nc -U /var/www/memcached.sock
How to read the stats section from the memcached command
@Cold-Egg provided above:
Important bits:
limit_maxbytes = max cache size in bytes
bytes = current utilization (if "bytes" is close to limit_maxbytes, increase the memory/cache size)
evictions = number of data that was removed from the cache before it had expired, usually because there is no more space for new data (if evictions stat increases, it is time to increase the cache size. Ideally evictions should be 0)
delete_miss - data that could not be found during delete operation, probably because of evictions or other factors.
Source
Complete stats descriptions from memcached:
Source
Code:
|-----------------------+---------+-------------------------------------------|
| Name | Type | Meaning |
|-----------------------+---------+-------------------------------------------|
| pid | 32u | Process id of this server process |
| uptime | 32u | Number of secs since the server started |
| time | 32u | current UNIX time according to the server |
| version | string | Version string of this server |
| pointer_size | 32 | Default size of pointers on the host OS |
| | | (generally 32 or 64) |
| rusage_user | 32u.32u | Accumulated user time for this process |
| | | (seconds:microseconds) |
| rusage_system | 32u.32u | Accumulated system time for this process |
| | | (seconds:microseconds) |
| curr_items | 64u | Current number of items stored |
| total_items | 64u | Total number of items stored since |
| | | the server started |
| bytes | 64u | Current number of bytes used |
| | | to store items |
| max_connections | 32u | Max number of simultaneous connections |
| curr_connections | 32u | Number of open connections |
| total_connections | 32u | Total number of connections opened since |
| | | the server started running |
| rejected_connections | 64u | Conns rejected in maxconns_fast mode |
| connection_structures | 32u | Number of connection structures allocated |
| | | by the server |
| response_obj_oom | 64u | Connections closed by lack of memory |
| response_obj_count | 64u | Total response objects in use |
| response_obj_bytes | 64u | Total bytes used for resp. objects. is a |
| | | subset of bytes from read_buf_bytes. |
| read_buf_count | 64u | Total read/resp buffers allocated |
| read_buf_bytes | 64u | Total read/resp buffer bytes allocated |
| read_buf_bytes_free | 64u | Total read/resp buffer bytes cached |
| read_buf_oom | 64u | Connections closed by lack of memory |
| reserved_fds | 32u | Number of misc fds used internally |
| cmd_get | 64u | Cumulative number of retrieval reqs |
| cmd_set | 64u | Cumulative number of storage reqs |
| cmd_flush | 64u | Cumulative number of flush reqs |
| cmd_touch | 64u | Cumulative number of touch reqs |
| get_hits | 64u | Number of keys that have been requested |
| | | and found present |
| get_misses | 64u | Number of items that have been requested |
| | | and not found |
| get_expired | 64u | Number of items that have been requested |
| | | but had already expired. |
| get_flushed | 64u | Number of items that have been requested |
| | | but have been flushed via flush_all |
| delete_misses | 64u | Number of deletions reqs for missing keys |
| delete_hits | 64u | Number of deletion reqs resulting in |
| | | an item being removed. |
| incr_misses | 64u | Number of incr reqs against missing keys. |
| incr_hits | 64u | Number of successful incr reqs. |
| decr_misses | 64u | Number of decr reqs against missing keys. |
| decr_hits | 64u | Number of successful decr reqs. |
| cas_misses | 64u | Number of CAS reqs against missing keys. |
| cas_hits | 64u | Number of successful CAS reqs. |
| cas_badval | 64u | Number of CAS reqs for which a key was |
| | | found, but the CAS value did not match. |
| touch_hits | 64u | Number of keys that have been touched |
| | | with a new expiration time |
| touch_misses | 64u | Number of items that have been touched |
| | | and not found |
| auth_cmds | 64u | Number of authentication commands |
| | | handled, success or failure. |
| auth_errors | 64u | Number of failed authentications. |
| idle_kicks | 64u | Number of connections closed due to |
| | | reaching their idle timeout. |
| evictions | 64u | Number of valid items removed from cache |
| | | to free memory for new items |
| reclaimed | 64u | Number of times an entry was stored using |
| | | memory from an expired entry |
| bytes_read | 64u | Total number of bytes read by this server |
| | | from network |
| bytes_written | 64u | Total number of bytes sent by this server |
| | | to network |
| limit_maxbytes | size_t | Number of bytes this server is allowed to |
| | | use for storage. |
| accepting_conns | bool | Whether or not server is accepting conns |
| listen_disabled_num | 64u | Number of times server has stopped |
| | | accepting new connections (maxconns). |
| time_in_listen_disabled_us |
| | 64u | Number of microseconds in maxconns. |
| threads | 32u | Number of worker threads requested. |
| | | (see doc/threads.txt) |
| conn_yields | 64u | Number of times any connection yielded to |
| | | another due to hitting the -R limit. |
| hash_power_level | 32u | Current size multiplier for hash table |
| hash_bytes | 64u | Bytes currently used by hash tables |
| hash_is_expanding | bool | Indicates if the hash table is being |
| | | grown to a new size |
| expired_unfetched | 64u | Items pulled from LRU that were never |
| | | touched by get/incr/append/etc before |
| | | expiring |
| evicted_unfetched | 64u | Items evicted from LRU that were never |
| | | touched by get/incr/append/etc. |
| evicted_active | 64u | Items evicted from LRU that had been hit |
| | | recently but did not jump to top of LRU |
| slab_reassign_running | bool | If a slab page is being moved |
| slabs_moved | 64u | Total slab pages moved |
| crawler_reclaimed | 64u | Total items freed by LRU Crawler |
| crawler_items_checked | 64u | Total items examined by LRU Crawler |
| lrutail_reflocked | 64u | Times LRU tail was found with active ref. |
| | | Items can be evicted to avoid OOM errors. |
| moves_to_cold | 64u | Items moved from HOT/WARM to COLD LRU's |
| moves_to_warm | 64u | Items moved from COLD to WARM LRU |
| moves_within_lru | 64u | Items reshuffled within HOT or WARM LRU's |
| direct_reclaims | 64u | Times worker threads had to directly |
| | | reclaim or evict items. |
| lru_crawler_starts | 64u | Times an LRU crawler was started |
| lru_maintainer_juggles |
| | 64u | Number of times the LRU bg thread woke up |
| slab_global_page_pool | 32u | Slab pages returned to global pool for |
| | | reassignment to other slab classes. |
| slab_reassign_rescues | 64u | Items rescued from eviction in page move |
| slab_reassign_evictions_nomem |
| | 64u | Valid items evicted during a page move |
| | | (due to no free memory in slab) |
| slab_reassign_chunk_rescues |
| | 64u | Individual sections of an item rescued |
| | | during a page move. |
| slab_reassign_inline_reclaim |
| | 64u | Internal stat counter for when the page |
| | | mover clears memory from the chunk |
| | | freelist when it wasn't expecting to. |
| slab_reassign_busy_items |
| | 64u | Items busy during page move, requiring a |
| | | retry before page can be moved. |
| slab_reassign_busy_deletes |
| | 64u | Items busy during page move, requiring |
| | | deletion before page can be moved. |
| log_worker_dropped | 64u | Logs a worker never wrote due to full buf |
| log_worker_written | 64u | Logs written by a worker, to be picked up |
| log_watcher_skipped | 64u | Logs not sent to slow watchers. |
| log_watcher_sent | 64u | Logs written to watchers. |
| unexected_napi_ids | 64u | Number of times an unexpected napi id is |
| | | is received. See doc/napi_ids.txt |
| round_robin_fallback | 64u | Number of times napi id of 0 is received |
| | | resulting in fallback to round robin |
| | | thread selection. See doc/napi_ids.txt |
|-----------------------+---------+-------------------------------------------|