my company has no dev ops person and I am developer so I hardly know the best practices of dev ops as I am new to it, so please forgive me for any mistake.

I have two Ubuntu machines. Each of them have a exact SAME web server and hence they give access logs. They both are running ruby on rails web server and using nginx.

Problem: Now I need a common place for viewing access Logs and web application logs.. And file caching should ofcourse be common to both web servers.

For this I have to come this solution: Have a separate server for storing cache and logs using NFS. So both the webservers will act as clients and store logs and cache in the NFS server.

I have also heard slightly about GFS.

Now cache is hardly going to get written once in hour or something but logs are written every second.

So I want to know what should I use for this problem ? NFS or GFS or both ? Which will give me the best performance ? Some people say use GFS as I researched a lot in the internet, but I want to know why GFS can be better then NFS in my case?

  • 1
    This is an absolutely terrible idea. You can't have a common cache, and you don't need common logs. If you insist you could send web server logs to syslog, and then send the relevant syslog messages to a third machine. But it's probably a lot easier to just copy all logs once a day to the third machine, for analysis. – Satō Katsura Sep 30 '17 at 7:18
  • Ok, thanks. But why can't I have a common cache, I have read everywhere that file caching should be common for all machines hosting webserver ? – user1735921 Sep 30 '17 at 16:09

If you want to send log from both servers to a third I advice you to use the syslog protocol (also proposed by @satō-katsura) with rsyslog packed in your ubuntu installation. You can find information googleling "apache syslog".

First redirect apache log to syslog in your apache virtual host configuration, for example :

ErrorLog  "|/usr/bin/tee -a /var/log/www/error.log  | /usr/bin/logger -t apache -plocal6.err"
CustomLog "|/usr/bin/tee -a /var/log/www/access.log | /usr/bin/logger -t apache -plocal6.info"


where local6 is the facility, err and info are the log level.

Then through rsyslog configuration send it to the third :

local6.* @<ip_dest>

Where ip_dest is the ip of the logging machine

Now you should receive the logs on the third and you can make on this one a rule to redirect those to a file :

# process remote messages
if $fromhost-ip == '<ip_host1>' or $fromhost-ip == '<ip_host2>' then {
        action(type="omfile" file="/var/log/apachecluster.log")

This should do the trick and you'll have a centralised log named apachecluster.log but be aware that You also can use logging tool to process logs on multiple machine such as Splunk

Concerning the cache you don't want some shared cache on network, you need to use a proxy that have some cache and that will log access etc. As you have said in your comment, you use google cloud for load balancing, it offers some caching abilities. Else just do with local cache of you apache hosts, you want cache in your ram, not in a the hard drive of a distant third computer.

Have fun

  • and what about cache? – user1735921 Sep 30 '17 at 15:49
  • @user1735921 I updated my answer with some cache related informations – M4rty Sep 30 '17 at 16:49
  • But its all about load balancing, I am already using load balancing from Google Cloud. – user1735921 Oct 1 '17 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.