i want store large number (millions) of user avatars in file system. files must uniformly distributed in file system scales more files added.
the avatars 5-10kb in size images. application asp.net mvc (c#)
storing:
consider these following unique user ids: bob, mike, robert, johnson avatar names bob.jog, mike.jpg, robert.jpg, johnson.jpg
html elements render avatar:
<img class="avatar" src="www.xyz.com/getavatar?user=bob" /> <img class="avatar" src="www.xyz.com/getavatar?user=mike" />
this go getavatar controller action avatar physical location , write response buffer
current architecture:
[httppost] public actionresult saveavatar(httppostedfile avatarimage, string user) { //get md5 hash of user (bob=9f9d51bc70ef21ca5c14f307980a29d8) //split md5 hash string folders (\9f\9d\51\bc\) //save avatar @ path <file_server>\images\9f\9d\51\bc\bob.jpg } [httpget] public actionresult getavatar(string user) { //get md5 hash of user (bob=9f9d51bc70ef21ca5c14f307980a29d8) //find file location md5 hash (9f\9d\51\bc\) //return <file_server>\images\9f\9d\51\bc\bob.jpg }
am way off on this? if yes, how architect this?
i use userid (auto generated new uuid) of user database in case have store userid in tables have username
thanks reading
i haven't seen way of creating folder structure, however, thought interesting.
assuming have million of users, do, 1 million users x 10kb near 10gb, it's not store.
the problem is, how many users access @ same time? if it's lot, server can slow deliver these files, because server has handle millions of access already.
if had website millions of users, wouldn't store avatars , content in application server, use cdn(content delivery network) store images, or dedicated server uploading images, such avatar.mydomain.com, upload domain via wcf.
Comments
Post a Comment