By Neel on Tuesday, 14 October 2014
Posted in General
Replies 49
Likes 0
Views 3.5K
Votes 0
I am on the process of learning on setting up a new server for installing Joomla with EasySocial. So I am creating this topic here so I can use this as a source for general discussion with Stackidea community here on this topic and also to share my input as I learn more over the next few weeks. First off, here is the Server Set-up that I am planning to have:

For webserver:
Nginx + Pagespeed + MariaDB + Php 5.6 + Php-FPM + Zend Opcode + Memcache

For VM:
Debian 7 + iptables + Fail2Ban
These are all good choices but I would be curious to see how you fair with php 5.6 and especially the version of MariaDB that you go with.

When I setup a server recently I went with php 5.5 and mariadb 10. The reason for these choices were conservative. With mariadb 10 you have a pretty much seamless dropin replacement for mysql. Beyond 10 mariadb has some divergence with mysql. So if you are conversant with the divergence then you can take advantage of the cutting edge of php 5.6 and mariadb but if not I would stick with 10 and save yourself headaches. I don't think that you will see major performance differences between php 5.5/5.6 and mariadb 10/+ unless you have a massive db and a very large audience.

I haven't followed Debian but if the 7 series is similar to the 7 series of CentOS then essentially the same applies. In terms of server OS the 7 series is cutting edge and some would say bleeding edge. I haven't gone there because I don't want the headaches even though I recognize that there are some significant performance gains promised. Personally I'd want to be well into the series of any of these three for a production server: centos, php, mysql/mariadb.

for nginx I ended up using the apache nginx combo with nginx as reverse proxy. I did this for several reasons including some methods I've been using for over a decade with apache. But you will probably do better with nginx if your only concern is performance.
·
Wednesday, 15 October 2014 00:17
·
0 Likes
·
0 Votes
·
0 Comments
·
Sounds good Neel, good idea to create a new thread on this. To those who want to see the conversation leading up to this thread: http://stackideas.com/forums/jch-optimize-vs-mod_pagespeed

Neel, as you pretty much are replicating the same setup I am running, I would be more than happy to help answer any questions you may have throughout the process. In a few hours from now I will take the time to share a bunch of tweaks and tips. Incl. more conf files than the ones I shared in the last thread.
·
Wednesday, 15 October 2014 02:43
·
0 Likes
·
0 Votes
·
0 Comments
·
P.S. I recommend Memcached over Memcache. More flexible, and integrates well with mod_pagespeed too.
·
Wednesday, 15 October 2014 02:44
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Paul, I am curious too to see how php 5.6 and the latest version of MariaDB goes. The reason I am trying with 5.6 first is because of the improved Zend opcode that is included as well as some of the improvements like reduced memory prints for POST, etc.. Worst case if I have trouble I might go back to 5.5. With MariaDB, hopefully there shouldnt me much issue I would think. Its good to know that I can use Mariadb 10 as a fallback if I had any issues.

With the Centos 7 and Debian 7 series there are a lot of difference. I wouldnt say Debian 7 is similar to Centos 7. Debian 8 will be a bit close to Centos 7 I would say but Deb8 wont be out until 2015 I think. Centos 7 has a lot of changes including Kernel 3.10+, has embraced systemd more, SElinux included and activated by default, has 10 year support, etc.. I found it really good but started having a few headaches when I have to start compiling the packages from source. It also requires a lot of additional library dependencies due to the 3.10+ kernel. Therefore I've switched to debian mainly due to the ease in installing compiled nginx with additional modules. I find debian way of file management a bit of a headache but getting used to it now. Also I wont be using cpanel this time so making the switch is no big deal for me atm.

With the Apache + Nginx combo, that is the set-up I have with one of my production site (although that doesnt have Joomla installed). I will be moving that to just Nginx and php-fpm for processing the php since this is more light weight I feel with the advantage of Nginx's event based. Instead of Apache + Nginx combo, some say that Apache + Varnish also does a better job. Something to consider if you prefer still using Apache.

Hi Jannik, Its great that my set up plan is the same / similar to yours. Having a company makes it easy. I just finished configuring my Nginx conf file. I will post back with how I have configured it.
·
Wednesday, 15 October 2014 05:25
·
0 Likes
·
0 Votes
·
0 Comments
·
This is the nginx conf file I am planning to use. Here I have also added the Filehandle cache settings, Gzip settings and the basic common settings that I will be used for all Vhosts like file caching, php handler, logging, etc..

user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log crit;
pid /run/nginx.pid;

events {
worker_connections 8096;
multi_accept on;
use epoll;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Filehandle Cache Settings
##

open_file_cache max=5000 inactive=30s;
open_file_cache_valid 60s;
open_file_cache_min_uses 3;
open_file_cache_errors on;

##
# Gzip Settings
##

gzip on;
gzip_disable "MSIE [1-6]\.";

gzip_vary on;
gzip_min_length 10240;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;


# ---------------------------------------
# Basic Settings for all VHosts
# ---------------------------------------

##
# Do Not Log Favicon
##

location = /favicon.ico {
log_not_found off;
access_log /dev/null;
}

##
# Do Not Log Robots.txt
##

location = /robots.txt {
allow all;
log_not_found off;
access_log /dev/null;
}

##
# Pass the PHP scripts to FastCGI server listening on UNIX Socket
##
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


##
# Client Side Caching of Files
##

location ~* \.(jpg|jpeg|gif|png|css|js|xml|txt)$ {
access_log off;
log_not_found on;
expires 30d;
}

location ~* \.(pdf|flv|swf)$ {
access_log on;
log_not_found on;
expires 14d;
}

location ~* \.(ico)$ {
expires 1y;
}

}



The vhost file will be more specific to Joomla settings.
# ---------------------------------------
# vHost http://www.example.com
# ---------------------------------------

server {

##
# Redirect http://www.domain.tld
##

server_name http://www.example.com;
rewrite ^(.*) http://example.com$1 permanent;

}

# ---------------------------------------
# vHost example.com
# ---------------------------------------

server {

##
# Basic Settings
##

listen 80;
server_name example.com;
root /var/www/example/public_html;
index index.php index.html index.htm default.html default.htm;

##
# Logging
##

access_log /dev/null;
error_log /var/www/example/logfiles/example.error.log notice;


# SUPPORT CLEAN (A.K.A. SEARCH ENGINE FRIENDLY) URLS IN JOOMLA
location / {
try_files $uri $uri/ /index.php?q=$request_uri;
}


# DENY RUNNING SCRIPTS INSIDE WRITABLE DIRECTORIES
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
return 403;
error_page 403 /403_error.html;
}


# Error Pages
error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

}

The above vhost file is not complete yet. I am yet to configure the php-fpm, Pagespeed, etc... I am also going to have a look and see how @Jannik had configured with the sample posted here
·
Wednesday, 15 October 2014 05:36
·
0 Likes
·
0 Votes
·
0 Comments
·
My nginx.conf

user www-data;
worker_processes 6;
pid /var/run/nginx.pid;
worker_rlimit_nofile 100000;

events {
worker_connections 10240;
multi_accept on;
use epoll;
}

http {

##
# Added by Linode Support to allow larger file uploads
##
client_max_body_size 4096m;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 600;


##
# Basic Settings
##
# -- Socket settings, see http://wiki.nginx.org/HttpCoreModule
connection_pool_size 8192;
client_header_buffer_size 4k;
large_client_header_buffers 8 8k;
request_pool_size 8k;

sendfile on;
sendfile_max_chunk 1m;
postpone_output 0;
tcp_nopush on;
tcp_nodelay on;

keepalive_timeout 30s;
types_hash_max_size 2048;
client_body_timeout 12;
client_header_timeout 12;
send_timeout 30;

output_buffers 8 32k;

# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log off;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/css application/xhtml+xml application/xml+rss application/rss+xml application/x-javascript application/javascript text/javascript application/json text/xml application/xml;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_vary on;

open_file_cache max=10000 inactive=30s;
open_file_cache_valid 60s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server_names_hash_bucket_size 128;
ssi off;
ssi_silent_errors off;
root /srv/http;

}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}



my.conf for MariaDB
# MariaDB database server configuration file.
#
# You can copy this file to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc_messages_dir = /usr/share/mysql
lc_messages = en_US
skip-external-locking
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
max_connections = 500
connect_timeout = 120
wait_timeout = 600
max_allowed_packet = 16M
thread_cache_size = 50
sort_buffer_size = 8M
bulk_insert_buffer_size = 16M
tmp_table_size = 256M
max_heap_table_size = 128M
#
# * MyISAM
#
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched. On error, make copy and try a repair.
myisam_recover = FORCE,BACKUP
key_buffer_size = 512M
open-files-limit = 65535
table-definition-cache = 4096
table_open_cache = 4096
myisam_sort_buffer_size = 512M
concurrent_insert = 2
read_buffer_size = 8M
read_rnd_buffer_size = 8M
#
# * Query Cache Configuration
#
# Cache only tiny result sets, so we can fit more in the query cache.
query_cache_limit = 4MB
query_cache_size = 64MB
# for more write intensive setups, set to DEMAND or OFF
#query-cache-type = 0
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# we do want to know about network errors and such
log_warnings = 2
#
# Enable the slow query log to see queries with especially long duration
#slow_query_log[={0|1}]
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 10
#log_slow_rate_limit = 1000
log_slow_verbosity = query_plan

#log-queries-not-using-indexes
#log_slow_admin_statements
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#report_host = master1
#auto_increment_increment = 2
#auto_increment_offset = 1
log_bin = /var/log/mysql/mariadb-bin
log_bin_index = /var/log/mysql/mariadb-bin.index
# not fab for performance, but safer
#sync_binlog = 1
expire_logs_days = 10
max_binlog_size = 100M
# slaves
#relay_log = /var/log/mysql/relay-bin
#relay_log_index = /var/log/mysql/relay-bin.index
#relay_log_info_file = /var/log/mysql/relay-bin.info
#log_slave_updates
#read_only
#
# If applications support it, this stricter sql_mode prevents some
# mistakes like inserting invalid dates etc.
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
default_storage_engine = InnoDB
# you can't just change log file size, requires special procedure
innodb_log_file_size = 256M
innodb_buffer_pool_size = 6G
innodb_log_buffer_size = 50M
innodb_file_per_table = 1
innodb_open_files = 1024
innodb_io_capacity = 1000
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb-log-files-in-group = 2
innodb-flush-log-at-trx-commit = 0
innodb_flush_method = O_DIRECT
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem



[mysqldump]
quick
quote-names
max_allowed_packet = 128M


[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 1024M

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
·
Wednesday, 15 October 2014 08:19
·
0 Likes
·
0 Votes
·
0 Comments
·
Cool.. That's great to refer to. I actually ended up adding buffer and timeout settings last night after I posted. I will compare the settings we have and see what's ideal to have. Couple of questions:

1) have you got a chance to explore nginx naxci yet? It looks interesting but I am wondering if this will end up causing more pain that gain.

2) I see from the notes that you had added client body size setting suggested by linode. Is this included in their normal support? I know you had sent that linode support is great but what is usually included in their support? Meaning being an unmanaged server, I assumed they will not support on server conf related questions since it's up to us. Is linode flexible with that? Or do you get paid support if you need any help with server set-up configuration?
·
Wednesday, 15 October 2014 15:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Nice, thanks for sharing this guys! Moving it to the tips area
·
Wednesday, 15 October 2014 18:41
·
0 Likes
·
0 Votes
·
0 Comments
·
Neel, I havent tried nginx naxci.

and in terms of Linode support including NGINX tweaks into their normal support, well... not that I am aware of. I got lucky, before switching to Linode I went on their mIRC and spoke with their CEO. They ended up hooking me up with a BETA for their Professional Services for free. Meaning they migrated my sites from MediaTemple to Linode for free and implemented a series of optimizations and tweaks which I requested. However, I did pay for managed, while they provided the free professional services. Generally speaking if you subscribe to Managed if you talk to the right people at Linode, they will really go out of the way for you. Without managed though, they do not touch the files on your server. They will only guide you.

Here is a blog update of the results of the BETA I was in, these are the streamlined support features you get with Managed and Professional Services now:
https://blog.linode.com/2014/09/30/linode-managed-is-even-better-than-before/ here is a blog update of their new managed and their professional services. It is out of beta now.

Basically what I did was, I spent a few months as a Managed subscriber, so I could get them to help me with everything and fix things that I messed up while playing around with things haha. Then as I got more and more comfortable doing things myself, I removed managed and upgraded specs instead.

A tip, if you have technical questions that are outside of the regular support, go on their mIRC there are a lot of incredibly talented people, including some of their support staff ready to answer technical questions.
·
Wednesday, 15 October 2014 22:14
·
0 Likes
·
0 Votes
·
0 Comments
·
Excellent. Its good to know.. I will keep this in mind when I choose the hosting provider. With or without managed service, I've only heard good reviews about Linode in general. And the recent changes they did couple of months ago has put them back in the lead again after a temporary shakedown by DO. Its good to have competitions.. More providers competing to be the best.
·
Wednesday, 15 October 2014 22:22
·
0 Likes
·
0 Votes
·
0 Comments
·
Neel, over the years I have tried an abundance of hosting providers. I generally am quite upset with the direction that most hosting providers have taken. It seems that most hosting companies try to find more and more ways to up sell even the most basic support features. However, with Linode for me it seems that they are trying to do more and more to provide a better service and more value. Since I switched to Linode half a year ago, I have seen nothing but continuous upgrades and improvements to their already amazing service.

They even have a beta section on their forums where they constantly are testing new features and services.

Not to mention it doesn't matter what time of day or night, the response time is anywhere from 1min to 15min... anything above that is out of the ordinary. I have never dealt with a host that provides so swift and detailed service.
·
Wednesday, 15 October 2014 22:39
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jannik,

I wish Linode had more datacentres around the world. That would have been perfect! There arent many providers that provided top notch service with quick response time and replying to emails without copying & pasting a standard cr script.

Anyhow, I am at the moment working out an ideal setting for php-fpm. Here are some that I am planning to experiment and thought I'll share it here:

1) I referred to your http://www.conf setting you had shared in the other topic here. Mine turned out to be pretty much similar to yours. However for the child processes, I am thinking of trying out `ondemand` instead of `dynamic`. I see most of the tutorials either suggests static or dynamic child processes but ondemand also make sense since it doesnt need to start a min process if its not needed. So for that, I have the following settings to try out:
; child processes
pm = ondemand
pm.max_children = 40
pm.process_idle_timeout = 35s
pm.max_requests = 500


With the max_children, I noticed that you had set 100 as the limit. Isint it a big number that can eat up a lot of RAM if all 100 child processes are running? I first had it at 10 first and have changed it to 40 (I'll probably be having the 4GB or the 8GB RAM plan).


2) I also added these settings to the php-fpm.conf file:
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s


I will next move on to MariaDB settings.
·
Wednesday, 15 October 2014 23:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Regarding data centers, wouldnt a cdn solve that?

Neel, your concerns about the max_children are valid... and setting it at 40 is perfect. I used to run my site at 20 before upgrading my server specs and it handled things just fine. However, do make sure to increase it beyond the basic 10, because if set to low you will end up having lots of issues down the road. I know I did.

and thanks for sharing your php-fpm.conf tweaks, that is one file that I hadnt gotten around to tweaking yet
·
Thursday, 16 October 2014 00:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Jannik,

Are you currently already hosting your site's on Linode? We're actually in the midst of deciding whether or not we should make the jump from Rackspace over to Linode.
·
Thursday, 16 October 2014 00:11
·
0 Likes
·
0 Votes
·
0 Comments
·
P.S. let me know how ondemand goes.
·
Thursday, 16 October 2014 00:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Yes Mark, let me know if you want to use my server as a testing ground.
·
Thursday, 16 October 2014 00:22
·
0 Likes
·
0 Votes
·
0 Comments
·
Jannik,

I have already purchased a machine from Linode but haven't start migrating but would like to run some tests on the network connectivity. The machine that we have currently with Rackspace is hosted in Chicago. The one at Linode is at Dallas. Not sure how good is their uptime. Have you encountered any downtimes with their network?
·
Thursday, 16 October 2014 00:25
·
0 Likes
·
0 Votes
·
0 Comments
·
Mark, I have not experienced any downtime what so ever. (Note: I host at their NYC datacenter)
·
Thursday, 16 October 2014 00:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for the input on this! Dallas would be better eh? Since it's pretty central
·
Thursday, 16 October 2014 00:52
·
0 Likes
·
0 Votes
·
0 Comments
·
Mark in your case definitely! I picked NYC to be central between US and Europe. But as users in Latin America and Asia gradually grow, I will consider moving it to Dallas.
·
Thursday, 16 October 2014 01:04
·
0 Likes
·
0 Votes
·
0 Comments
·
Ah, I see. Thanks for the heads up on this Jannik
·
Thursday, 16 October 2014 01:12
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark, I think you have to analyse your google analytics and see where most of the users are coming from. I do think Dallas to be pretty central cuz its also a little closer to Australia, New Zealand, Malaysia, Japan, India, Philippines traffic. Its also not far from Europe neither. So it does look like a central to me. Map
·
Thursday, 16 October 2014 02:03
·
0 Likes
·
0 Votes
·
0 Comments
·
How much memory do you guys think we need to leave aside for php?. Lets say I have a 8 GB Ram server for a Joomla site with Easysocial which is ofcourse mostly php, would you say having 1024, 1536M or even 2048MB ram for php to be useful? I am unsure how much to start off with cuz MySql is also a beast that needs a lot of RAM, Nginx uses some and RAM is the most expensive that needs to be correctly used to keep everything happy. What would you do?

Right now I have 'memory_limit = 1024M' and thinking if I should even give upto 2GB for it.
·
Thursday, 16 October 2014 02:36
·
0 Likes
·
0 Votes
·
0 Comments
·
I used to be having like 128M for php memory limit on a 1.5 GB Ram. I am now moving to a 8GB ram server and I am figuring out how to distribute them and how much memory limit do I set. Will having more memory limit to php benefit at all, doesnt make a difference or would it be a waste..
·
Thursday, 16 October 2014 02:44
·
0 Likes
·
0 Votes
·
0 Comments
·
Neel, the way I deal with tuning for memory is simple. I always set my values a bit too high for breathing room, and keep an eye on my ram usage. If I feel the ram usage is too high I limit things a bit. But to be honest, a lot of these values are theoretical, many of them you will not reach if your settings are tuned correctly. In my case CPU has been hardest to get under control, Memory has always been very easy to keep at a comfortable place.
·
Thursday, 16 October 2014 03:18
·
0 Likes
·
0 Votes
·
0 Comments
·
How do you monitor these.. Does linode web console provide a way to monitor these ram and cpu usages?
·
Thursday, 16 October 2014 03:29
·
0 Likes
·
0 Votes
·
0 Comments
·
Yes it does They have something called Longview, there is a free and a paid version. Both are incredible. (The paid version just lets you go back in time more and get a more detailed overview)
·
Thursday, 16 October 2014 03:57
·
0 Likes
·
0 Votes
·
0 Comments
·
Dallas / Houston are the homes of a lot of the major and minor data centers. You can however improve latency with Europe by using an east coast dc. Talk to an online gamer and they will confirm this for you. The original backbone of the Internet was run out of Virginia and grew out from there. Also if your audience is primarily in the United States, don't assume that Dallas/Houston are "central" any more than Chicago is just because they are roughly geographically central. Your audience is about people, not geography. Most of the U.S. population concentration is on the eastern half of the U.S., notwithstanding that Los Angeles is the most populated city. Also to be considered is that on the western half of the geography the lion's share of the population is extreme west, not evenly distributed from say west of the Mississippi to California. Instead it is highly concentrated in the west coast metros: Los Angeles/San Diego, San Fran Bay Area, Portland OR, Seattle, WA with a few large metros in between a massive area of Geography: Phoenix, Las Vegas

·
Thursday, 16 October 2014 06:04
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for the heads up on this Paul.
·
Thursday, 16 October 2014 12:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jannik,

Today I was configuring he MySQL settings. While doing so, I was using your sample as a reference to see how you did yours to get an idea (again thanks for sharing. It was so useful for a guidance). I have a few questions on these settings if you dont mind:

1) With the innodb log file size I noticed that you had only allocated about 256M while the innodb buffer pool size is allocated upto a massive 6G. Dont you think you might find a better performance if you maybe increased the log file size to a higher value? Some recommends a 25% rule (25% of buffer pool size) for this. I have set this up as 1gb for log file size and 5g for buffer pool size. Your views?

2) With Joomla, I noticed it uses InnoDB storage engine. So is there any point in allocating 512M for MyISAM's key buffer size? I am thinking if I should perhaps give MyISAM a lower value since I dont see when MyIsam might be used with the current version of Joomla 3.

3) With the Query cache settings, I havent done any changes to the default values and left it as it is. I also read that this can be a huge bottleneck and we might not even need this if using memcached for it. Is that right? So if I have memcache, can I disable Query Cache in my.conf? I see that you have set cache limits for this and I am curious to know more..

4) When I set the open-file-limit, I also realised that I need to increase this value in the system limits by editing `/etc/security/limits.conf. Did you do the same?

5) Lastly, after editing the settings in my.cnf, is there any other settings I might need to edit with the main "system" settings that you can think of that might limit the rules set in my.cnf? (similar to open-file-limit overridden by system's hard limit).

Here is the mysql configuration I am thinking of having. I am only pasting the conf I have edited / changed for easy readability. If a setting is not listed here, then I havent touched them and left it as default. Please do let me know if I missed something or if it can be improved upon:

[mysqld]

#
# * Fine Tuning
#
max_connection = 500
connect_timeout = 120
wait_timeout = 600
max_allowed_packet = 16M
thread_cache_size = 128
sort_buffer_size = 8M
bulk_insert_buffer_size = 16M
tmp_table_size = 256M
max_heap_table_size = 256M

#
# * MyISAM
#

myisam_recover = BACKUP
key_buffer_size = 512M
open-files-limit = 65535
table_open_cache = 400
myisam_sort_buffer_size = 512M
concurrent_insert = 2
read_buffer_size = 6M
read_rnd_buffer_size = 3M

#
# * InnoDB
#
innodb_log_file_size = 1024M
innodb_buffer_pool_size = 5G
innodb_log_buffer_size = 30M
innodb_file_per_table = 1
innodb_open_files = 1000
innodb_io_capacity = 1000
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_flush_method = O_DIRECT


[mysqldump]
max_allowed_packet = 128M

[isamchk]
key_buffer = 512M



Hope you dont mind me analysing every bit of your conf.
·
Thursday, 16 October 2014 21:58
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jannik,

I have found the answers to the questions I had before (the ones I had posted in my last post). So here it is for the completion purposes:

1) It is better to have innodb log files to a bigger size. I find setting it to about 20% of the innodb buffer pool size to be ideal for it. Therefore I have set the log file size to 1GB.

2) I have allocated 512M to MyIsam because some extensions still uses this storage engine. However, I do prefer to change the storage engine for these ext to InnoDb if it doesnt use any specific feature that is only available in MyIsam. Most of them are already compatible with innodb with no problem. However I do find it valid to allocate a small space for MyIsam too (atleast for now) until all extensions and tables start using only InnoDb.

3) With the query cache, I will be setting a small limit for it since it can be a bottleneck. However memcached will add the extra layer of doing a better job on this.

4) For the Open file limit on mysql storage engine, it is necessary to make sure that the system limits are also increased. If not the system's hard limit will limit the counts used for this setting.

5) AFAI, its only the open file limit and max user connection settings that can be limited by system's limits.


One more thing: For the max_memory_limit in php.ini, I have reduced it down to 128M. I initially had to for 1GB before which was ridiculously high (and because I misunderstood the purpose of max memory limit). After understanding its purpose, I think limiting it to 128M or max 256M should be good enough. If having it to a big number like 1GB, it can eat the ram and bring down the system if there were badly written scripts with infinite loop and if a hacker pushes the system to crash.

Hope these helps....
·
Sunday, 19 October 2014 16:36
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jannik,

I am currently looking into Memcached for setting it up. I just realized that there are 2 kinds of memcached server that we can use:

1) The standard memcached server (I believe that is what you were referring to) that stores the key-value data in RAM.

2) There is now a InnoDB memcached plugin included since MySQL 5.6 which uses the innodb buffer pool and also the data is persistent. I've been reading on this and its been interesting and could be more useful

Can you tell me how you installed memcached and which one you went with for your server?
·
Sunday, 19 October 2014 21:31
·
0 Likes
·
0 Votes
·
0 Comments
·
Ah sweet, thanks for updating me on your findings. Please elaborate on the whole InnoDB memcached plugin as that is news to me
·
Sunday, 19 October 2014 21:37
·
0 Likes
·
0 Votes
·
0 Comments
·
Okay, here is what I have understood from it so far.. What the InnoDB memcached is doing is, when you install this plugin it creates a separate table in MySql to store the key-value pairs. So when a memcache(d) client is querying the DB through InnoDB memcached server, it looks at the table cache and gives it straight from it (similar to what std memcached server does). If it doesnt exist, then after compiling the sql and fetching the data, it then stores the key-value pair inside the mysql table. The beauty of this is, since the table is controlled by InnoDB, the table is always available in RAM through buffer pool and InnoDB's architecture already does an awesome job making sure that the data are not stale. So its like 2 birds in one go (1) It uses innodb buffer pool itself (2) the data are more accurate and reliable than the std memcached server. The topping on the ice is, because Key-value pair is stored inside a table, the data is always persistent. This is something you cant get through std memcached that uses shared memory. So even if you restart your server, you dont loose the cache and it doesnt add a strong overhead in setting everything up once again. Seems to me like worthy enough as a replacement to the std memcached server.

First when I reading about these, I was so confused what the difference between so many memcache, memcached, innodb memcached, memcached server, etc.. cuz there are limited docs out there on innodb memcache (the oracle's docs are good though). But after reading and reading on this for couple of days, this is my understanding on this is so far. Here are a few links I found that helped me understand these a bit:

http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-intro.html
http://dev.mysql.com/doc/refman/5.6/en/innodb-memcached-benefits.html
http://blog.ulf-wendel.de/2013/toying-with-peclmysqlnd_memcache-and-mysql-5-6-memcache-innodb/


If anyone know about this or have tried this, please do share with us.
·
Sunday, 19 October 2014 21:59
·
0 Likes
·
0 Votes
·
0 Comments
·
What values did you set for your limits.conf, I have:
mysql soft nofile 50000
mysql hard nofile 100000
·
Monday, 20 October 2014 06:27
·
0 Likes
·
0 Votes
·
0 Comments
·
By the way in terms of the memory limit, where you said that 1gb was too high. I got that value from the JomSocial documentation. They recommended 1gb. I am assuming it will come into play when uploading and converting videos with ffmpeg, that requires very memory intensive scripts..
·
Monday, 20 October 2014 06:40
·
0 Likes
·
0 Votes
·
0 Comments
·
By the way, I dont know if I have mentioned it before. But I only use Memcached for Joomla Sessions, and I use File Cache for Joomla Caching. (With an SSD, File Cache is faster than Memcached for Joomla)
·
Monday, 20 October 2014 06:48
·
0 Likes
·
0 Votes
·
0 Comments
·
By the way, how do you know what extensions are compatible with InnoDb? I have not tried converting storage engines for anything, but it makes sense.
·
Monday, 20 October 2014 06:51
·
0 Likes
·
0 Votes
·
0 Comments
·
Jannik Laursen wrote:

What values did you set for your limits.conf, I have:
mysql soft nofile 50000
mysql hard nofile 100000

I have these atm. I think 8GB ram specs machine should be able to handle this although I dont see me reaching the hard limit number.
Hard limit: 65536
Soft limit: 32768

This is how I've set it up in limits.conf (first one is for all users and the second one is for root user which separate and doesnt respect all user settings)

	# wildcard does not work for root, but for all other users
* hard nofile 65536
* soft nofile 32768
# settings should also apply to root
root hard nofile 65536
root soft nofile 32768



Jannik Laursen wrote:

By the way in terms of the memory limit, where you said that 1gb was too high. I got that value from the JomSocial documentation. They recommended 1gb. I am assuming it will come into play when uploading and converting videos with ffmpeg, that requires very memory intensive scripts..

1GB is a very big number for memory limit and that can eat up the ram and exceed the system limits quickly and that is why I am not comfortable to start with 1GB straight away. But you are right, if you are uploading videos, it will need a lot of memory. For example if you are uploading say a 10MB video which are really compressed in most formats, by the time the script decompresses it, it can to become a 50MB file or more.. So yeah it will need more memory to process videos. But having said that, I feel it is a safer approach to start with a lower number for the memory limit and then scale it upwards rather than starting with a big number and scaling it downwards. Also another thing to keep in mind is, we should be able to make a rough estimate on how much space we might need to allocate based on the max upload size. If a user cant upload more than the max upload size, then having big memory limit will not be of any particular use. If I have video processing involved, I might start with 256 first, if its not enough rise it to 512 and gradually increase it. This way when it reaches a limit you will know which script is consuming that much memory and why. Much safer than not knowing which scripts are eating a lot of memory when starting with a big memory limit cuz you will never know when something eats up like say 900MB of memory which is a lot but doesnt throw an error since its still below the limit set.
Jannik Laursen wrote:

By the way, I dont know if I have mentioned it before. But I only use Memcached for Joomla Sessions, and I use File Cache for Joomla Caching. (With an SSD, File Cache is faster than Memcached for Joomla)

So does that mean that memcached is used only for saving sessions in ram and not for storing the Sql data too? Wouldnt it be more useful if it can be used for storing sql datas? Does Joomla support that and how does that work? I'll like to know since I am unsure on how it works with Joomla queries, is it possible to cache them with Memcached or does it require additional set-up etc....

Jannik Laursen wrote:

By the way, how do you know what extensions are compatible with InnoDb? I have not tried converting storage engines for anything, but it makes sense.

First it depends on what version of MySql (or Mariadb) you have and second it depends if the extension is using any specific features that is only available in MyIsam. For example, the first few releases of Innodb (I think before MySql 5.6) did not support fulltext search index and MyIsam does. So if an ext uses full text and you change to Innodb, then you either loose those features in ext or better update your InnoDB to the latest version. Innodb doesnt support spatial search index and MyIsam does. Usually I check with the extension author first before I change the storage engine to innodb (I did that with K2 since I can make most use of it if I changed it to Innodb as its read heavy). But generally speaking its safe to assume that most of these extensions should work with innoDb as a drop-in replacement.

Hope these helps in some ways
·
Monday, 20 October 2014 16:17
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Mark, I am in a dilemma over memcache(d) and it's mainly trying to understand if it's going to be worth having it or not. Can you plz help me understand these plz:

1) is there really a benefit of using memcached with Joomla +ES or would having this actually increase the load times instead of reducing it?

2) I have been reading mixed opinions about it. Some say the joomla core may gain from using memcache but if there are extensions installed, it can actually increase the load times. Here is one article on this: http://www.cloudaccess.net/about-us/blog/entry/2013/07/30/is-memcache-slowing-down-your-joomla-site.html
How does ES work with memcache? If it's enabled, would ES use memcache to cache sql queries?

3) What is your view on this? I mean, would you use memcache on your server with Easysocial installed?

@Jannik, I know you recommended using memcached. Have you noticed any significant difference after installing memcached on your server? If so, can you share how much improvement did memcache give you plz?
·
Friday, 24 October 2014 00:20
·
0 Likes
·
0 Votes
·
0 Comments
·
I never used memcached before so I really can't tell the difference. Perhaps Jannik could shed some lights on this?
·
Friday, 24 October 2014 01:01
·
0 Likes
·
0 Votes
·
0 Comments
·
Memcached is fantastic for Database, because it means that it doesnt have to run common queries from scratch over and over again. It retrieves them from the cache.

Memcached is also fantastic for storing your ngx_pagespeed files. (I only disabled it because I felt that it was causing conflicts with my CDN or development workflow... I forget why I disabled it... but it was great when I tried it. Will most likely enable it again)

However, in my experience File Caching is way faster than Memcached for regular Joomla caching. Do note however, that you must have an SSD for the File Caching to be faster than Memcached. With me Memcached actually slowed down my site.
·
Friday, 24 October 2014 02:27
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you Jannik. I have installed Memcached now and I'll see how that goes.

@Mark, does EasySocial use Memcached/Memcache if it is enabled? I know you've said you dont use it, but in order to benefit from memcache the php application (ES in this case) should specifically need to look and cache queries in memcache if not basically it is not using memcache even if it is installed in the server. So does ES use memcache if enabled? Is there a way to enable memcache(d) for ES so it uses the caching feature? This could be useful for many tasks used in social network to speed things up by caching the frequently used or big queries into memcache(d).
·
Sunday, 26 October 2014 16:26
·
0 Likes
·
0 Votes
·
0 Comments
·
Hello Neel,

Nope, EasySocial wasn't optimized for memcached but I think as long as the database layer in Joomla uses memcached, EasySocial would be able to benefit from it since most of the SQL queries in EasySocial are done via Joomla's database layer.
·
Monday, 27 October 2014 00:39
·
0 Likes
·
0 Votes
·
0 Comments
·
Subscribe
·
Friday, 31 October 2014 23:05
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Jannik,

How have you been. Its been awhile since I saw you around.

A quick question. Just a couple of days ago I realised that EasySocial does not use InnoDB as their DB Engine. From your mysql config you had posted above, I saw that you have allocated most of your server RAM (like 6G) for InnoDB so it works best and only 512M for MyIsam. So I was wondering, did you know that ES uses (and specifies) MyIsam and not InnoDB? Have you manually changed the database engine for Easysocial from MyIsam to innoDB so you can make the most of it with your setting? Can you let know how you tuned ES storage engine please?

Here the topic on this: http://stackideas.com/forums/easysocial-db-storage-engine
·
Monday, 10 November 2014 16:39
·
0 Likes
·
0 Votes
·
0 Comments
·
Subscribe
·
Tuesday, 18 November 2014 16:35
·
0 Likes
·
0 Votes
·
0 Comments
·
hi,

About this configuration : MariaDB + Php 5.6 + Php-FPM + Zend Opcode ,it should be more better mariadb+php 7+php FPM + ZEND OPCODE.

Php 7 it`s twice as fast as php 5.6,and will be released soon,except that is does not work with Memcached.

Mariadb is the future choice as google and wikipedia,already adopted it.

Joomla configuration must be tweaked up in order to work with memcached.

Zend opcode cache is only good when used with PHP FPM,else it won`t give the wanted results.

Innodb is more good to be used instead of Myisam,in order to scale and if you have high traffic or alot of stuff in that database.

My experience with k2 component i guess you all now this component i used before i use easyblog 5,i did have k2 with over 200k items on it,the tables was myisam ,the problem started when the table was mostly over 100k items,it did continued to crash constantly.

The table was myisam,in order that easyblog to not make the same mistake,i do relate my bad history about this,when they release 2.6.8 they did go to InnoDb,the problem it was the the innodb would be applied only in new installation,not on upgrade from k2 2.6.7 to 2.6.8 for example.

As the table on my side did remain MYISAM,the crashing did continued all over again.

The server admins advised me to convert those tables into InnoDb,in order to be able to take the traffic and solve the problem,all good,but on that time i was using mysql 5.5 witch does not know some variable: get full text ,and some tables did have that variable.
Only from mysql 5.6 innodb knows about the get full text variable from myisam and can be converted.

When i did upgrade to mysql 5.6,all went wild,on an dedicated machine with 8 threads and 4gb of ram,the cpu was at 100% all the time,thing that makes impossible to operate any changes or stuff .Cpu is :Intel Xeon Quad Core 2.5GHz (8 threads)

Later on i find it out ,that it was an query unoptimized from k2 that was doing the whole mess.

I was forced to upgrade to mariadb,i did that,and it was an great surprise,because the cpu was high but it drop down to about 70% when using mariadb,and i was able to correct and fix the problem.

After fixing the problem,the cpu was down to 0.5 -0.3 cpu usage.

I did use this version of mariadb : 10.0.21-MariaDB ,and on it :Easyblog5,komento and easydiscuss.

I think that in order to scale,in future version stackideas should think on this :

-How to use InnoDb instead of Myisam
-how to use innodb but to not do same mistake as k2 did done,and the tables were not converted on upgrade to the newest version of k2.

Mostly they did not done this,because they writed in an blog post "crappy host " ,but the real problem i think is not the crappy host,i think the upgrade won`t be possible from myisam to innodb,if your running mysql 5.5,as you need mysql 5.6 in order to convert that variable from myisam to innodb,and that can cause an real problem.

I think something most done,like for example in the release,to be mention:the tables will be upgrade to innodb only if you have mysql 5.6 in your server and not mysql 5.5 ,if mysql 5.5 is detected,it should remain Myisam,in order to not break the things on that website.

Joomla is using Innodb,joomla will be php 7 compatible on 1st december,they will release it then,hopefully with php 7 with opcache+php fpm,things should be alot more better.

Jannik,you wroted that SSD file for cache is more good then Memcached,memcached as you writed more up and is corectly : "Memcached is fantastic for Database, because it means that it doesnt have to run common queries from scratch over and over again. It retrieves them from the cache" is corectly,in joomla we have cache handler and sesion handler,as memcached does not work with php 7,as host mostly does not have ssd because the price is still high on ssd comparated to normal hard disk,what do you think it will be solution for handling session and cache handler?

From what i know basically memcached stored things into the RAM,witch is way more faster then using the cpu.

The problem is what you do if you have 1 milion html let`s say simple html text+images no videos?How much of your Ram it will eat up that ?

If you store them as file on your side,it will eat up of your hard drive space from your server,if you don`t have enough disk space,this might not be an suitable solution .

What i was thinking is,if somehow this cache can be deployed on an SSD on CLOUD ? Instead of using your server space for file cache.

As with cloud practically you can scale as you grow,but on an dedicated machine,you have some resources,but those resources might not be enough as you grow and if you wish to grow.

If you grow,it does not mean neccesary that you make more money,it means that you just grow,and it can mean that you have to spend more on resources in order to run things out else you might shutdown your whole website.

I think that togheter,we definetely should find an solution to this problem,in order to be able to scale things at minimum cost,or cost that are paid based on the grow,so you can do some plans and estimation of price,else the project might fail.

And this can be leveraged after that with using CDN for example cloudflare cdn witch is free or others.

I saw an nice option on jomsocial called : Remote Storage ,and in there you can setup,were you can store the files into :local server or amazon s3 and on right you can configure the amazon s3 settings and bucket .

Except that amazon lunched early this year,amazon cloud drive : https://www.amazon.com/clouddrive/home/, witch is :
Unlimited Everything
Securely store all of your photos, videos, files and documents for just $59.99 per year.

Is an very good price,but i wonder,if this cloud drive or others can be integrated with joomla,or stackideas products,in order for example to not keep those files into your server,to keep them into the cloud,as practically you can`t scale and grow without cloud.

Maybe this option of remote storage can be added on easyblog 5,easy social ,or even both amazon s3 and amazon cloud drive.

If cloud integration is being made,it can really make an difference and help that business owner to grow his site,along with stackideas products.
·
Monday, 26 October 2015 23:00
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey electro,

Thanks for your insights on this. EasySocial does have Amazon S3 support as well but the Cloud Drive is pretty interesting. I think it does allow you to store it but it doesn't allow you to serve it on the web. Take a look at the comparison here, http://www.headinthecloudstorage.com/amazon-ec2-and-s3-whats-the-difference/

It would be a no brainer to kill their own S3 product wouldn't it
·
Monday, 02 November 2015 19:37
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post