{"id":2777,"date":"2016-09-23T18:17:41","date_gmt":"2016-09-23T22:17:41","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2777"},"modified":"2017-11-24T18:06:48","modified_gmt":"2017-11-24T23:06:48","slug":"php-memcached-instances-ubuntu-16","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/","title":{"rendered":"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16"},"content":{"rendered":"<h1>How to distribute PHP sessions on multiple memcached instances on Ubuntu 16<\/h1>\n<p>Memached is an open-source distributed memory caching system commonly used to speed up dynamic websites by, as the name suggests, caching data objects in RAM. By caching the data in RAM, Memcached is able to reduce the number of times that the database or API must be read when performing operations on the website. Memcached is free to use and runs on Linux, OS X, and Microsoft Windows. Available under the Revised BSD license, it is possible to install the Memcached host-client infrastructure on your own Ubuntu 16 servers.<\/p>\n<p>This tutorial will cover the process of PHP session saving and replication for Ubuntu 16 on multiple Memcached servers.<\/p>\n<h2>Getting Started<\/h2>\n<p>For completing this tutorial, you will need the following setup for a landscape with three servers running Ubuntu 16:<br \/>\n\u2022 1 <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\"><b>Small Server<\/b><\/a>\/<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\"><b>Cloud Instance<\/b><\/a> (to be used for HAProxy)<br \/>\n\u2022 2 Web Servers\/Cloud Instances (to run Apache, PHP and Memcached)<\/p>\n<p>Kindly note that before proceeding, you are able to act as the root user on all three servers. All commands in this tutorial, unless otherwise specified, must be executed as the root user or using the command sudo (when possessing superuser privileges) to act as root.<\/p>\n<h2>Tutorial<\/h2>\n<p>Throughout the tutorial, we will refer to the servers in our landscape using the following information in the table below. This information includes the hostname for each server, its Public IP, LAN IP, and the services that should be running on it. Make sure to refer back to this table whenever you may need to confirm which server an instruction should be executed on for a quick overview of the landscape.<\/p>\n<p><code class=\"gris\">Server Hostname Public IP LAN IP Services Running<br \/>\nLB1 173.209.44.220 10.0.0.96 Haproxy<br \/>\nWEB1 173.209.44.221 10.0.0.97 Apache, PHP, Memcached<br \/>\nWEB2 173.209.44.230 10.0.0.98 Apache, PHP, Memcached<\/code><\/p>\n<h2>Initial Setup for All Three Servers<\/h2>\n<p>We will begin the process with the preparation steps that must be executed on all three servers. During this preparation, you will have to ensure that the system is up to date, the firewall is disabled, and the servers are running with the latest kernel.<\/p>\n<p>As root, on each node execute the following command using the native Ubuntu package manager apt to update the local package index with the latest information concerning available packages and package versions:<\/p>\n<p><code>apt-get update<\/code><\/p>\n<p>After fetching the new package information, apt must then be used again in order to upgrade the installed packages with available updates:<\/p>\n<p><code>apt-get upgrade<\/code><\/p>\n<p>Your Ubuntu server comes equipped with a firewall known as the Uncomplicated Firewall, or ufw. While it is disabled by default, likely you have enabled it as some prior point. For this tutorial, we will need to disable the firewall. This is done easily with the ufw command:<\/p>\n<p><code>ufw disable<\/code><\/p>\n<p>To know whether the kernel version will need to be updated, check the current version of the kernel using the uname command:<\/p>\n<p><code>uname -r<\/code><\/p>\n<p>The output of this command will look somewhat like the following (depending on which version is installed):<\/p>\n<p><code class=\"gris\">4.4.0-22-generic<\/code><\/p>\n<p>The latest version at this time of writing is 4.7. If you have any other version, you can update your kernel by downloading the required packages from the Ubuntu website. First, make sure you have the web utility wget, which will allow you to download files. Install wget if you do not have it using apt:<\/p>\n<p><code>apt-get install<br \/>\napt-get upgrade<\/code><\/p>\n<p>Finally, reboot the server for the changes to take into effect.<\/p>\n<p><code>reboot<\/code><\/p>\n<p>Verify that you are now running the new kernel version using uname a second time:<\/p>\n<p><code>uname -r<\/code><\/p>\n<p>Don&#8217;t forget to run all the steps in this section on all three servers before proceeding to the next section.<\/p>\n<h2>Proxy Server Configuration for the HAProxy Node<\/h2>\n<p>This section will concern itself with the configuration of the node that you will use for your HAProxy load-balancer. HAProxy is a free open-source software that provides load-balancing, high-availability, and proxying services for both TCP and HTTP applications. For the purposes of this guide, we will provide a basic HAProxy configuration that should be suitable out of the box for the majority of applications.<\/p>\n<p>On your dedicated HAProxy server, begin by installing the HAProxy package as root:<\/p>\n<p><code>apt-get install haproxy<\/code><\/p>\n<p>After the package finishes installing, you will need to enable HAProxy with the following command as it is disabled by default:<\/p>\n<p><code>sed -i \"s\/ENABLED=0\/ENABLED=1\/g\" \/etc\/default\/haproxy<\/code><\/p>\n<p>You can start the HAProxy service after enabling it by executing:<\/p>\n<p><code>\/etc\/init.d\/haproxy start<\/code><\/p>\n<p>However, you must complete some further configuration steps for HAProxy before you can use it. Open up the configuration file haproxy.cfg in the text editor vi:<\/p>\n<p><code>vi \/etc\/haproxy\/haproxy.cfg<\/code><\/p>\n<p>Remove all the contents from the open configuration file. Next, insert the following code to create the new configuration file. This will add a listener on port 80 on localhost for HTTP and port 443 for HTTPS:<\/p>\n<p><code class=\"gris\">global<br \/>\nlog 127.0.0.1 local2<br \/>\nchroot \/var\/lib\/haproxy<br \/>\npidfile \/var\/run\/haproxy.pid<br \/>\nmaxconn 4096<br \/>\nuser haproxy<br \/>\ngroup haproxy<br \/>\ndaemon<br \/>\nstats socket \/var\/run\/haproxy.cmd<br \/>\ndefaults<br \/>\nmode http<br \/>\nlog global<br \/>\noption httplog<br \/>\noption dontlognull<br \/>\noption httpclose<br \/>\noption forwardfor except 127.0.0.0\/8<br \/>\noption redispatch<br \/>\nretries 3<br \/>\ntimeout http-request 10s<br \/>\ntimeout queue 1m<br \/>\ntimeout connect 10s<br \/>\ntimeout client 45s<br \/>\ntimeout server 45s<br \/>\ntimeout check 10s<br \/>\nmaxconn 4096<br \/>\nlisten http :80<br \/>\nmode http<br \/>\nbalance roundrobin<br \/>\noption forwardfor<br \/>\noption httpclose<br \/>\noption http-server-close<br \/>\ntimeout http-keep-alive 3000<br \/>\nhttp-request del-header Proxy<br \/>\nserver web1 10.0.0.94:80 weight 1 check inter 3000 rise 2 fall 1<br \/>\nserver web2 10.0.0.95:80 weight 1 check inter 3000 rise 2 fall 1<\/code><\/p>\n<p>Save and close the configuration file once you are done editing it. Restart HAProxy for your changes to take into effect:<\/p>\n<p><code>\/etc\/init.d\/haproxy restart<\/code><\/p>\n<p>To enable the HAProxy service to start on boot (recommended), use the update-rc.de command as shown:<\/p>\n<p><code>update-rc.d haproxy defaults<\/code><\/p>\n<p>You can check the status of HAProxy at any time to verify it is working by checking the output of the following:<\/p>\n<p><code>service haproxy status<\/code><\/p>\n<h2>Configure the Web Servers for Apache, PHP, and Memcached<\/h2>\n<p>Once you have set up your dedicated HAProxy node, you will now have to configure your two remaining web servers. The steps in this section will need to be executed twice, once on each server.<\/p>\n<p>Begin by installing the packages for the Apache web server, PHP, and Memcached using apt. We will also install some PHP extensions as well the PHP-Memcache extension. This package provides integration functions for Memcached into your applications as well as activating Memcached support in other existing applications. Be careful when typing the name of the PHP-Memcache extension. There is another library that is not suitable for the purposes of this guide that is named php-memcached. Double check that you are instead typing the name of the extension we need, which is php-memcache (without the letter &#8220;d&#8221;). This package is lighter and has less dependencies than php-memcached.<\/p>\n<p><code>apt-get -y install apache2 php libapache2-mod-php php-mcrypt memcached php-memcache libmemcached-devel php-pecl-memcache httpd <\/code><\/p>\n<p>When the installation of the packages completes, you will need to configure the Apache web server, particularly the ServerName directive. You can do this by opening the following file using the text editor vi:<\/p>\n<p><code>vi \/etc\/httpd\/conf\/httpd.conf<\/code><\/p>\n<p>Modify this file to include the following line with the a server name of your choice, which can represent the site or infrastructure. This will be used in order to easily and quickly identify the server.<\/p>\n<p><code class=\"gris\">ServerName mysite.com<\/code><\/p>\n<p>Save and close the file to proceed. Next, you will need to verify that PHP has been properly installed and that the Memcached library is present. You can do this by checking the output of the following command, which will call PHP with the -m option to show compiled modules, before passing the output to grep using a pipe (&#8220;|&#8221;). grep will search the output it receives for the term &#8220;memcache&#8221; and return successfully if it is found.<\/p>\n<p><code>php -m | grep memcache<\/code><\/p>\n<p>After verifying that PHP and PHP-Memcache have been installed, the Memcached module will need to be configured in order to allow distributed PHP sessions. Open the memcache.ini file in the text editor vi:<\/p>\n<p><code>vi \/etc\/php\/7.0\/mods-available\/memcache.ini<\/code><\/p>\n<p>You will need to again remove everything that is already in this file by default. Replace the contents with the following:<\/p>\n<p><code class=\"gris\">extension=memcache.so<br \/>\nmemcache.maxreclevel=0<br \/>\nmemcache.maxfiles=0<br \/>\nmemcache.archivememlim=0<br \/>\nmemcache.maxfilesize=0<br \/>\nmemcache.maxratio=0<br \/>\nmemcache.hash_strategy = consistent<br \/>\nmemcache.allow_failover = 1<br \/>\nmemcache.session_redundancy = 3<\/code><\/p>\n<p>Be careful that the memcache.session_redundancy parameter has a value that corresponds to one plus the sum of your configured Memcached instances. This means that if you have two Memcached servers, you will need to enter 3 as the value. Interestingly enough, this PHP bug has never been fixed despite being widely known.<\/p>\n<p>With the Memcached configuration complete for now, we will move on to configuring PHP to store its user sessions. Open the php.ini file for editing with vi:<\/p>\n<p><code>vi \/etc\/php.ini<\/code><\/p>\n<p>Search this file for the line session.save_handler = files. When you find this line, delete it. In the same space as the deleted line was previously, insert the following two lines:<\/p>\n<p><code class=\"gris\">session.save_handler = memcache<br \/>\nsession.save_path = \"tcp:\/\/10.0.0.94:11211, tcp:\/\/10.0.0.95:11211\"<\/code><\/p>\n<p>You will also need to repeat this process for the CLI-related php.ini file. Open the file for editing, delete the session.save_handler = files line, and replace it with the two lines specified above. This will be useful if you have cron (a task scheduler) jobs running PHP scripts that require session access.<\/p>\n<p>Please ensure that you have repeated the above steps for the two servers before proceeding to the following section.<\/p>\n<h2>Configuration for the Two Memcached Servers<\/h2>\n<p>Both of the Memcached servers will need to be configured in order to allow Memcached to listed on their private LAN IPs. You will also need to modify the amount of memory that is allocated to each instance in this section.<\/p>\n<p>The goal of this guide will be to set both the servers to accept 1024 connections coming from Apache processes with a cache size of 256MB per server. Such a cache size is large enough in order to store thousands of PHP sessions in RAM and works for most applications. Note that for a heavy usage scenario, it will be necessary to increase the size.<\/p>\n<p>To begin, open the Memcached configuration file with vi:<\/p>\n<p><code>vi \/etc\/sysconfig\/memcached<\/code><\/p>\n<p>You will need to modify the file contents so that they match the following. Note that the IP listed must be the respective machine&#8217;s LAN IP that you are currently working on. Remember to change it when you repeat these steps for the second server.<\/p>\n<p><code class=\"gris\">PORT=\"11211\"<br \/>\nUSER=\"memcached\"<br \/>\nMAXCONN=\"1024\"<br \/>\nCACHESIZE=\"256\"<br \/>\nOPTIONS=\"-l 10.0.0.95\"<\/code><\/p>\n<p>Restart Memcached and Apache to accept the new changes:<\/p>\n<p><code>systemctl restart httpd.service<br \/>\nsystemctl restart memcached.service<\/code><\/p>\n<p>To enable these two services to run on boot, which is recommended, execute additionally the following lines:<\/p>\n<p><code>systemctl enable httpd.service<br \/>\nsystemctl enable memcached.service<\/code><\/p>\n<p>Remember again that all of the above steps must be executed on both servers in order for Memcached to run before proceeding.<\/p>\n<h2>Testing PHP Sessions Creation and Balancing<\/h2>\n<p>To ensure that our landscape has been successfully configured to the correct state, we will place a script on both the web servers that will help test the sessions and load balancing. More particularly, we will need to ensure that sessions are being created in the first place, and then that the sessions are being balanced between the two web servers. All the steps in this section must be executed on both the servers.<\/p>\n<p>First, navigate to the default Apache webroot located in \/var\/www\/html. This repository is the source of what is being hosted on the server, and where we will create the test script. Use the following commands to change directories using cd and create the script file:<\/p>\n<p><code>cd \/var\/www\/html<br \/>\nvi session.php<\/code><\/p>\n<p>With the file open for editing in the text editor vi, insert the following code to form the session PHP script:<\/p>\n<p><code class=\"gris\">&lt;?php<br \/>\nheader('Content-Type: text\/plain');<br \/>\nsession_start();<br \/>\nif(!isset($_SESSION['visit']))<br \/>\n{<br \/>\necho \"Welcome from GloboTech! Thank you for visiting this server.\\n\";<br \/>\n$_SESSION['visit'] = 0;<br \/>\n}<br \/>\nelse<br \/>\necho \"You have visited this server \".$_SESSION['visit'] . \" times. \\n\";<br \/>\n$_SESSION['visit']++;<br \/>\necho \"Server IP: \".$_SERVER['SERVER_ADDR'] . \"\\n\";<br \/>\necho \"Client IP: \".$_SERVER['REMOTE_ADDR'] . \"\\n\";<br \/>\nprint_r($_COOKIE);<br \/>\n?&gt;<\/code><\/p>\n<p>After saving and closing the file, we now need to visit this script using the load balancer IP address. By using the load balancer IP address (the HAProxy server), some visits will end up on the WEB1 server, while others will access the WEB2 server instead. Open the script at the following URL in your browser:<\/p>\n<p><code class=\"gris\">http:\/\/173.209.44.220\/session.php<\/code><\/p>\n<p>When the page is open, the output should look as follows:<\/p>\n<p><code class=\"gris\">Welcome from GloboTech! Thank you for visiting this server.<br \/>\nThis server has seen you 30 times.<br \/>\nServer IP: 10.0.0.95<br \/>\nClient IP: 10.0.0.93<br \/>\nArray<br \/>\n(<br \/>\n[PHPSESSID] =&gt; aeoj7s47i7ke2l0fr7b534v684<br \/>\n)<\/code><\/p>\n<p>Check the session ID that is output to ensure that is remains the same for each load, and that the total amount of visits increases by one upon refresh as it should. Keep refreshing until you end up on the other web server, at which point the visitor counter should still be increasing and the PHPSESSID should be the same. The output should look like the following sample:<\/p>\n<p><code class=\"gris\">Welcome from GloboTech! Thank you for visiting this server.<br \/>\nThis server has seen you 31 times.<br \/>\nServer IP: 10.0.0.94<br \/>\nClient IP: 10.0.0.93<br \/>\nArray<br \/>\n(<br \/>\n[PHPSESSID] =&gt; aeoj7s47i7ke2l0fr7b534v684<br \/>\n)<\/code><\/p>\n<p>If all looks correct, we can now confirm that the session is persisting across different web servers. With a second browser open to the same page, refresh a couple of times so that a session ID is created.<\/p>\n<h2>Testing Failover Memcached Servers<\/h2>\n<p>Switch to the load balancer node. To test the Memcached servers, you will need to install the additional netcat utility that will allow you to query the servers for their statistics. Install it with:<\/p>\n<p><code>apt-get install netcat<\/code><\/p>\n<p>Use netcat to see the statistics of any given server by executing:<\/p>\n<p><code>echo 'stats' | nc 10.0.0.94 11211<\/code><\/p>\n<p>This will check the statistics of the first web server. The output should look as follows:<\/p>\n<p><code class=\"gris\">STAT pid 28882<br \/>\nSTAT uptime 39<br \/>\nSTAT time 1471052900<br \/>\nSTAT version 1.4.15<br \/>\nSTAT libevent 2.0.21-stable<br \/>\nSTAT pointer_size 64<br \/>\nSTAT rusage_user 0.016870<br \/>\nSTAT rusage_system 0.020244<br \/>\nSTAT curr_connections 5<br \/>\nSTAT total_connections 104<br \/>\nSTAT connection_structures 6<br \/>\nSTAT reserved_fds 20<br \/>\nSTAT cmd_get 1<br \/>\nSTAT cmd_set 195<br \/>\nSTAT cmd_flush 0<br \/>\nSTAT cmd_touch 0<br \/>\nSTAT get_hits 0<br \/>\nSTAT get_misses 1<br \/>\nSTAT delete_misses 0<br \/>\nSTAT delete_hits 0<br \/>\nSTAT incr_misses 1<br \/>\nSTAT incr_hits 0<br \/>\nSTAT decr_misses 0<br \/>\nSTAT decr_hits 0<br \/>\nSTAT cas_misses 0<br \/>\nSTAT cas_hits 0<br \/>\nSTAT cas_badval 0<br \/>\nSTAT touch_hits 0<br \/>\nSTAT touch_misses 0<br \/>\nSTAT auth_cmds 0<br \/>\nSTAT auth_errors 0<br \/>\nSTAT bytes_read 10212<br \/>\nSTAT bytes_written 2598<br \/>\nSTAT limit_maxbytes 268435456<br \/>\nSTAT accepting_conns 1<br \/>\nSTAT listen_disabled_num 0<br \/>\nSTAT threads 4<br \/>\nSTAT conn_yields 0<br \/>\nSTAT hash_power_level 16<br \/>\nSTAT hash_bytes 524288<br \/>\nSTAT hash_is_expanding 0<br \/>\nSTAT bytes 202<br \/>\nSTAT curr_items 2<br \/>\nSTAT total_items 195<br \/>\nSTAT expired_unfetched 0<br \/>\nSTAT evicted_unfetched 0<br \/>\nSTAT evictions 0<br \/>\nSTAT reclaimed 0<br \/>\nEND<\/code><\/p>\n<p>Next, you can execute the same command as above in order to check the statistics of the second server:<\/p>\n<p><code>echo 'stats' | nc 10.0.0.95 11211<\/code><\/p>\n<p>This will also provide output like the following:<\/p>\n<p><code class=\"gris\">STAT pid 28117<br \/>\nSTAT uptime 50<br \/>\nSTAT time 1471052915<br \/>\nSTAT version 1.4.15<br \/>\nSTAT libevent 2.0.21-stable<br \/>\nSTAT pointer_size 64<br \/>\nSTAT rusage_user 0.013569<br \/>\nSTAT rusage_system 0.039201<br \/>\nSTAT curr_connections 5<br \/>\nSTAT total_connections 103<br \/>\nSTAT connection_structures 6<br \/>\nSTAT reserved_fds 20<br \/>\nSTAT cmd_get 97<br \/>\nSTAT cmd_set 291<br \/>\nSTAT cmd_flush 0<br \/>\nSTAT cmd_touch 0<br \/>\nSTAT get_hits 96<br \/>\nSTAT get_misses 1<br \/>\nSTAT delete_misses 0<br \/>\nSTAT delete_hits 0<br \/>\nSTAT incr_misses 1<br \/>\nSTAT incr_hits 96<br \/>\nSTAT decr_misses 0<br \/>\nSTAT decr_hits 0<br \/>\nSTAT cas_misses 0<br \/>\nSTAT cas_hits 0<br \/>\nSTAT cas_badval 0<br \/>\nSTAT touch_hits 0<br \/>\nSTAT touch_misses 0<br \/>\nSTAT auth_cmds 0<br \/>\nSTAT auth_errors 0<br \/>\nSTAT bytes_read 21822<br \/>\nSTAT bytes_written 8479<br \/>\nSTAT limit_maxbytes 268435456<br \/>\nSTAT accepting_conns 1<br \/>\nSTAT listen_disabled_num 0<br \/>\nSTAT threads 4<br \/>\nSTAT conn_yields 0<br \/>\nSTAT hash_power_level 16<br \/>\nSTAT hash_bytes 524288<br \/>\nSTAT hash_is_expanding 0<br \/>\nSTAT bytes 202<br \/>\nSTAT curr_items 2<br \/>\nSTAT total_items 291<br \/>\nSTAT expired_unfetched 0<br \/>\nSTAT evicted_unfetched 0<br \/>\nSTAT evictions 0<br \/>\nSTAT reclaimed 0<br \/>\nEND<\/code><\/p>\n<p>These statistics for the servers show that activity has occurred on this instance, as expected. Both Memcached servers should have had activity and stored content. Still, it is important to note that while Memcached does utilize replication, it is not 100% fail proof. This means that if one of the two Memcached servers were to shut down, for any reason, we would not be able to guarantee that both servers did in fact contain the same exact sessions. However, if such a case were to occur, it is no cause for worry as the affected users would only need to login again to their accounts.<\/p>\n<p>To test the failover, shutdown Memcached on any of the two web servers (but not both!) with the command:<\/p>\n<p><code>systemctl stop memcached.service<\/code><\/p>\n<p>Refresh the browser page you have open and observe the behavior. Does the visit counter continue to increase when you refresh the page? If so, then the failover setup is working as it should.<\/p>\n<p>If the counter did not increase, but rather stayed the same, we will need to make an additional test to confirm that replication is working correctly. Restart Memcached on the instance you stopped it on:<\/p>\n<p><code>systemctl restart memcached.service<\/code><\/p>\n<p>Now, you will have to go onto the other server and kill the Memcached instance there instead. On the second server (web1 for example), kill Memcached using:<\/p>\n<p><code>systemctl stop memcached.service<\/code><\/p>\n<p>Go to your webpage again. If the counter increases upon refresh, then you can safely confirm that your Memcached PHP session setup works correctly with both failover and replication.<\/p>\n<h2>Conclusion<\/h2>\n<p>Congratulations! While setting up PHP session replication on multiple Memcached Ubuntu 16 servers is a lengthy process, it pays off in terms of the speed boost it gives to dynamic web applications you may be running such as WordPress or Moodle. Share this tutorial with your friends if you found it useful!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to distribute PHP sessions on multiple memcached instances on Ubuntu 16 Memached is an open-source distributed memory caching system commonly used to speed up dynamic websites by, as the name suggests, caching data objects in RAM. By caching the data in RAM, Memcached is able to reduce the number of times that the database<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-2777","post","type-post","status-publish","format-standard","hentry","category-ha-clustering"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to distribute PHP sessions on multiple memcached instances on Ubuntu 16 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to distribute PHP session on multiple Memcached servers on Ubuntu 16. Read Now &amp; Start using memory caching !\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to distribute PHP session on multiple Memcached servers on Ubuntu 16. Read Now &amp; Start using memory caching !\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-23T22:17:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-24T23:06:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/\",\"name\":\"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-09-23T22:17:41+00:00\",\"dateModified\":\"2017-11-24T23:06:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to distribute PHP session on multiple Memcached servers on Ubuntu 16. Read Now & Start using memory caching !\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16 - Globo.Tech","description":"This tutorial will show you how to distribute PHP session on multiple Memcached servers on Ubuntu 16. Read Now & Start using memory caching !","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/","og_locale":"en_US","og_type":"article","og_title":"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16 - Globo.Tech","og_description":"This tutorial will show you how to distribute PHP session on multiple Memcached servers on Ubuntu 16. Read Now & Start using memory caching !","og_url":"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/","og_site_name":"Globo.Tech","article_published_time":"2016-09-23T22:17:41+00:00","article_modified_time":"2017-11-24T23:06:48+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/","url":"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/","name":"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-09-23T22:17:41+00:00","dateModified":"2017-11-24T23:06:48+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to distribute PHP session on multiple Memcached servers on Ubuntu 16. Read Now & Start using memory caching !","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/php-memcached-instances-ubuntu-16\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to distribute PHP sessions on multiple memcached instances on Ubuntu 16"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2777","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2777"}],"version-history":[{"count":4,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2777\/revisions"}],"predecessor-version":[{"id":4462,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2777\/revisions\/4462"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2777"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2777"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2777"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}