Scalable way to store files on server (PHP)?

Posted by Nathaniel Bennett on Stack Overflow See other posts from Stack Overflow or by Nathaniel Bennett
Published on 2012-10-22T22:43:26Z Indexed on 2012/10/22 23:00 UTC
Read the original article Hit count: 121

Filed under:
|
|
|
|

I'm creating my first web application - a really simplistic online text editor. What I need to do is find the best way to store text based files - a lot of them. These text files can be past 10,000 words in size (text words not computer words.) in essence I want the text documents to be limitless in size.

I was thinking about storing the text files in my MySQL database - but thought there was a better way. Instead I'm planing on storing the text files in XML based format in a directory on my server. The rows in the database define the name of the xml based text file and the user who created the text along with basic metadata. An ID is generated using a V4 GUID generator , which gives the text an id and stores the text in the "/store" directory on my server. The text definitions in my server contain this id, and the android app I'm developing gets the contents of the text file by retrieving the text definition and then downloading the text to the local device using the GUID in the text definition.

I just think this is a botch job? how can I improve this system?

There has been cases of GUID colliding. I don't want this to happen. A "slim" possibility isn't good enough - I need to make sure there is absolutely no chance in a GUID collision. I was planning on checking the database for texts that have the same id before storing the text with a particular id - I however believe with over 20,000 pieces of text in my database this would take an long time and produce unneeded stress on the server.

How can I make GUID safe?

What happens when a GUID collides?

The server backend is going to be written in PHP.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql