galvin Posted August 18, 2011 Share Posted August 18, 2011 I will have a website that will have thousands of images (some uploaded by me, some uploaded by users). They will all be small images, but there will be tons. In general, what is the better option for optimal performance of the site... 1. Allow users to upload images to a directory on my site's web server 2. Instruct users to upload images to a 3rd party image hosting site, and only allow them to enter the "hot link" of the image. I realize #2 would likely cost me some money since I'd likely need a "pro" account at whichever image hosting company I go with to allow for unlimited bandwidth (since there will be lots of hot-linking), but it's likely only around $5 a month. And it's a little more work for the user as well. But is #2 the better way go to, generally speaking? It just seems like if there's going to be thousands of images, keeping them off my web server would help overall site performance. Thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/ Share on other sites More sharing options...
thehippy Posted August 18, 2011 Share Posted August 18, 2011 I used to be a programmer on a forum site well known for its (NSFW) gallery. If you host the images on your web (application) hosting account you can run into problems with disc space, bandwidth and resource usage. The load on the webserver from distributing images can take up significant resources. What we ended up doing is setting up an nginx webserver on a colo box hosted at peer1 dedicated to just image serving and resizing (making thumbs). From what I was told we pushed out 1.2TB from the image server and maybe only a few gigs from the application server a day. As for the premium image hosting, I don't have experience with that, the NSFW nature of the content we had made such things unavailable. Splitting up the load definitely was the right choice in our situation. I can see a problem though with what you said, having your users go offsite to upload pictures is clumsy, I wonder what impact it would have on your users' attention. Some transparency by integrating an upload mechanism might be beneficial. Be wary of the image hosting sites as well by reading over user agreement closely. Some sneak in things like giving rights to reuse images which may be a problem for you. Another thing came to mind, you also said your images were small, could you knit them together into a sprite and have CSS sort it out displaying them? It would cut down on the number of requests to the server. There are many things you can do to speed up your website, google has a whole section of articles and talks about the subject. I don't know if I said anything useful. Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1259022 Share on other sites More sharing options...
galvin Posted August 18, 2011 Author Share Posted August 18, 2011 You definitely said some useful things Thanks you very much! Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1259038 Share on other sites More sharing options...
Philip Posted August 18, 2011 Share Posted August 18, 2011 I'd also suggest looking into setting up a separate server of yours for just static images. Nginx servers static files super quick with a very small footprint. On larger sites (especially forums) I have it setup to where the actual forum is getting served via one server (and possibly one mysql server) and then one "media" server that hosts all the images/videos/etc. Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1259065 Share on other sites More sharing options...
galvin Posted August 18, 2011 Author Share Posted August 18, 2011 Thanks! I use HostGator for my web application files (shared hosting for now, but I anticipate enough traffic ultimately where I'll need to upgrade my hosting to a more capable server). Do you recommend setting up my own Nginx server (like in my house), or can i get an Nginx server through a 3rd party (like HostGator or someone else)? Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1259094 Share on other sites More sharing options...
Philip Posted August 18, 2011 Share Posted August 18, 2011 It depends on what you need really & what your timeline is. I'd suggest playing around with it on a local box (if you have one readily available), get used to nginx. Then step up to a VPS or dedi (in this case, probably a small VPS) when you're ready to push it to the live site. Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1259112 Share on other sites More sharing options...
galvin Posted September 8, 2011 Author Share Posted September 8, 2011 The more I think about this, the more I think I'll pursue having a separate server whose only purpose is to host the images for my website. Question about this. If the domain of my regular site is mysite.com, then what could the URL be of the images on my new, separate server? In other words, they couldn't be at the domain mysite.com since that domain is hosted on the OTHER server, right? Or wait, can you host a subdomain on SEPARATE server? For example, could I host "images.mysite.com" on the separate server (which would allow all the image URLs to have URLs like images.mysites.com/monkeys.jpg)? Any insight would be appreciated (I'm hesitant to use a 3rd party image hosting site because I want to have control of my images, since there will evenutally be a TON of them). Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1266968 Share on other sites More sharing options...
Philip Posted September 8, 2011 Share Posted September 8, 2011 For the separate domain I typically stick with static.domain.com or cdn.domain.com (usually this). And yes, you can host a subdomain on a separate server, just point the A record in the DNS settings to the correct IP. Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1267034 Share on other sites More sharing options...
ZulfadlyAshBurn Posted September 8, 2011 Share Posted September 8, 2011 you would need a CDN for this. it really helps. try cdninabox.com. It was created using Google Apps Engine and is used by many Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1267055 Share on other sites More sharing options...
galvin Posted September 9, 2011 Author Share Posted September 9, 2011 If I decide to keep all files (including images) on one server, would it at least help to still use a subdomain. Like... HTML/CSS hosted on mysite.com Images hosted on static.mysite.com Both domains would be on the same server, but would this at least help a bit with speed? Seems there is something called "parallel downloads" that is a positive thing. Just curious, as I want to explore all options here Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1267216 Share on other sites More sharing options...
Philip Posted September 9, 2011 Share Posted September 9, 2011 Yup, it will help with speed. Also, later if you decide to switch to a real cdn / other server, then its pretty much upload the files to the other server(s) and point your new DNS to it. Quote Link to comment https://forums.phpfreaks.com/topic/245109-hosting-images-on-web-server-vs-3rd-party-image-host/#findComment-1267220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.