Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do they do it???

Status
Not open for further replies.

imstillatwork

IS-IT--Management
Joined
Sep 26, 2001
Messages
1,605
Location
US
Blogspot.com for example.

each user gets a subdomain, that's easy.

now it also appears that each blog entry is saved as HTML, I would assume for less web application server load / less DB action. I like that, also easy to do.

My curiosity is with how they store the users files.

a url example would be thisguy.blogspot.com/2006/12/this-is-a-blog-entry.html

or

thisOTHERguy.blogspot.com/2006/12/another-blog-entry.html

now this gives a 404
thisOTHERguy.blogspot.com/2006/12/this-is-a-blog-entry.html

I'm trying to guess how they organize user data. I have a site that will have a lot of users, and would like to keep their data separate, or organized somehow, rather than for example, throw all the user uploaded images into one folder.

I know a modern server can handle 100's of millions of files / subfolders, but even if i had 50,000 users, I don't know that a folder for each is the best way to go.

So i'm trying to figure out a good way to store files for 1000,s and 1000's of users effectively.



Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
I manage kinda forum of my company and use the <TEXTAREA> tag for input..

Since the postings is not too heavy (yes, it depends), I decided to put the posts by week of current year in the default "data" folder. Not too pretty, but it's the simplest way in my case.

In order to make the upcoming html filename unique, d, h, n, and s part of DATEPART are use to construct it, preceeded with a default prefix.

Then CFFILE is used in writing user's input to html file.

The last part is storing the created file to a database for later use.
Code:
<cfset sFolder = "Week#datepart('yyyy',now())##week(Now())#">
<cfif NOT directoryExists("#expandpath('data')#/#sFolder#")>
<cfdirectory action="CREATE" directory="#expandpath('data')#/#sFolder#" mode="777">
</cfif>

<cfset sFileName="log_#numberformat(datepart('d',now()),'0_')##numberformat
(datepart('h',now()),'0_')##numberformat(datepart('n',now()),
'0_')##numberformat(datepart('s',now()),'0_')#">

<cfset file2store = "data/#sFolder#/#sFileName#.html">

<CFFILE ACTION="write" 
   FILE="#expandpath('data')#/#sFolder#/#sFileName#.html"
	accept="htm" nameconflict="MAKEUNIQUE"
    OUTPUT="#Form.txtUserInput#"
	MODE=777>

Do an insert query to store the file location to your database.

Please note that you may need to check the user's input and make some necessary changes to "executable" tags. For instance:
'<' to '&lt;'

Regards,
mansii
 
oh, yeah I understand the concepts of saving the files and storing data no problem. This is more of a data organization on a large scale question. Multiple users, and keeping their data separate in some sense. I'll have no problem coming up with more than a few ways to do it, but wanted some information about a very good way to do it.



Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Appologize, Kevin.
Didn't mean to throw such simple codes. You helped me before.
I would like to discuss about data organization on a large scale myself.
Seemed that I couldn't catch your question.
But storing users' data in their own folders is enough for me.
Just an opinion.

Regards,
mansii
 
Hey Kevin, I understand what you're saying and maybe you've already looked at this and rejected the idea, but this is what I do.

I store the user info in the dB and a large text dump, nvarchar(8000), blob or whatever the case might be.

So my dB schema would be:
Table: myTable
Columns: myTable_ID, User_ID, UserInfo

If the user uploads images and files then I have a folder by the username and inside that folder I have two other subfolders (images and docs) so the entire folder structore would be: [root] -> [Usernmame] -> Images, docs

This allows me to seperate each user and their files from one another.



____________________________________
Just Imagine.
 
mansii, no problem, It was probably me that has a hard time writing questions that really mean what I want them to.

GUJUm0deL:
I've been leaning that direction, and I've done it before. How many users have you had on a site organized like that?


Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Kevin, approx 20K registered users. And, the site i'm building now i'm using the same logic. I've had no issues whatsoever with this route, plus it's easy to maintain. I can share the code, if anything to compare and contrast better coding style/logic.

____________________________________
Just Imagine.
 
20K, good to know. I know any modern os can handle 100's of millions of folders and files, so this should be ok. I guess I need to see what other people do before I am confident in what I should do.

My usernames are already checked for formating for use as a subdomain, so they will be safe for use as folder names also.

If there was anything that you though was worth noting, I'd be interested in seeing your examples. I'm always up for seeing other peoples code. It's cool how different we can do the exact same thing.



Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top