title: XML vs MySQL for Large Sites
body: <p>For a <strong>very large site</strong> such as a Social Network (say Facebook), which method would you recommend for user accounts storage?</p>
  
  <p>1) Single XML files for each type of features, on the user's directory: <em>basicinfo.xml, comments.xml, photos.xml, ...</em></p>
  
  <p>2) MySQL, although not sure how to organize on this. Maybe separated tables for each feature? E.g. a tables for Comments, where columns are <em>id,from,message,time</em>?</p>
  
  <p>I know XML is not designed for storage, and PHP (this is the language I use) must read the entire XML file and store in memory before it is used.</p>
  
  <p>But, here are the reasons why I prefer XML (but I may be wrong, please tell me if you disagree with any):</p>
  
  <p>1) If I have user accounts' paths organized in this way</p>
  
  <blockquote>
    <p>User ID 2342:<br>
    /users/00/00/00/00/00/00/00/23/42/</p>
  </blockquote>
  
  <p>I think it's faster to find the Comments of a user by file path than seeking in a large database.<br>
  Also, if each feature is split in tables, each user profile will seek more than once, to display comments, photos, basic info, etc.</p>
  
  <p>2) I heard MySQL is globaly locked when writing on it. Is this true? If yes, I rather to lock a single file than everything.</p>
  
  <p>3) Is MySQL "shared" between the cluster? I mean, if 1 disk gets full, will it "continue" on another? Or do I, as the programmer, have to manage it myself and create new databases on another disk? (note, I use Linux)<br>
  It is ok that it is about the same by using XML files, but it is easier to split between disks, because structure is split by account IDs, not by feature as it would be in a database.</p>
  
  <p>4) Note that I don't store each comment on the <em>comments.xml</em>. I just note their attributes in each XML tag, and the messages are in separated text files <em>commentid.txt</em>. Once each XML should not be much large, there should not be problems with memory/time.</p>
  
  <p>As for the problem of parsing entire XML, maybe I should think on using XMLReader/Writer instead of SimpleXML/DOM? Or, will it decrease performance allot?</p>
  
  <p>Thank you!</p>