1753501 Members
3430 Online
108794 Solutions
New Discussion юеВ

NFS Vs Database

 
Vishwa
Occasional Advisor

NFS Vs Database

Hello,

We are having multiple Linux servers serving our PHP based application in our production environment. We are using a load balancer to route the requests according the the server load.

We plan to use one of the following methods to share the session info across servers:

NFS oriented : In this method we plan to mount (NFS mount) one of the folders of one system onto other servers. The shared file system will serve as session data repository for all the servers.

Database oriented : In this method the session repository is a table in a database. The session data is logged into the common table and all the servers would use the common table for storing the session. Hence the request can be routed to any system serving the application.

I would like to know which one of the above approaches would give us better performance.

As you all would have tried the NFS for many purposes, I thought this is an appropriate place to post my question. Forgive me if this is not appropriate in this forum.

Thanks in advance,
Vishwa
When going gets tough, upgrade. ┬й Murphy.
2 REPLIES 2
Vincent Fleming
Honored Contributor

Re: NFS Vs Database

Your performance in this would be application dependent.

I would think that the database would be faster, though - but that's a guess.

Personally, I would do something completely different. Writing a very small client/server application using TCP/IP sockets would be fairly simple (if you have someone who has done this in C before), and perform the best.

Specifically, have one server with a daemon (that you write) that listens on a socket, and takes session information from the other servers, who send the session info via connecting to the socket. The Daemon can keep the session info in memory, and give it back out when asked by one of the clients.

You would have to add code to the client to send and retrieve session information from this server, but you're planning on doing that anyway (for NFS or database).

It would be more development, but significantly faster in production... at least in my opinion.

Good luck!
No matter where you go, there you are.
Stuart Browne
Honored Contributor

Re: NFS Vs Database

With the origonal question in mind, the database method will provide you with better stability, and faster access.

NFS, whilst wonderful in it's abilities, is slow and cumbersome with a considerable overhead on all machines compared to throwing small pieces of information in a dedicated database.

Assuming you don't have a bottleneck in your network, go that way.

It doesn't have to be some high-powered be-all-and-end-all db server, something simple like MySQL is probably all that's required. But if you've got something big (or that you're comfortable using) already, use it.
One long-haired git at your service...