A client asked me to create an image for him, and he wants me to set up a script that will track how many times the image is clicked AND how many times the image is loaded. He wants this displayed for him in the WP dashboard so I don't think I can use the servers access logs. I have never done anything like this, so I turn to the stackoverflow community. :)
Can somebody just point me in the right direction? Thanks a million.
The easiest way is probably just to use to the access logs of your web server (for Apache, the most common one, check: http://httpd.apache.org/docs/2.0/logs.html). Here every hit (both the link page and the image) is logged, so you can get the information from that.
Most web servers have some tools available that can make this a bit easier than counting by hand (or with grep); just search the web for your web server + log analyzer (e.g. http://awstats.sourceforge.net/ for Apache). If you're not hosting the site yourself, chances are that your web host has pre-installed such a tool for you already.
Related
So, for a simple test game, I'm working on generating user images based on their current in-game avatar. I got this idea from Club Penguin and GTA V. They both generate images of the current in-game avatar.
I created a script to simply put a few images together and print out the final image to the client. It's similar to how Club Penguin does it, I believe: http://cdn.avatar.clubpenguin.com/%7B13bcb2a5-2e21-442c-b8e4-10516be6abc6%7D/cp?size=300
As you can see, the penguin is wearing multiple clothing items. The items are each different images located at http://mobcdn.clubpenguin.com/game/items/images/paper/image/300/ (ex: http://mobcdn.clubpenguin.com/game/items/images/paper/image/300/210.png)
Anyway, I've already made the script and all, but I have a few questions.
When going to Club Penguin's or Grand Theft Auto's avatar generator, you'll notice it finishes the request so fast. Even when it's a new user, (so before it has a chance to cache the image since it hasn't been generated yet), it finishes in under a second.
How could I possibly speed up the image generation process? Right now I'm just using PHP, but I could definitely switch over to another language. I know a few others too and I'm willing to learn. Which language can provide the fastest web-image generator (it has to connect to a database first to grab the user avatar info)?
For server specs, how much RAM and all that fun stuff would be an okay amount? Right now I'm using an OVH cloud server (VPS Cloud 2) to test it and it's fine and all. But, if someone with experience with this could help, what might happen if I started getting a lot more traffic and there were people with 100+ image requests being made per client when they first log in (relationship system that shows their friend's avatar). I'll probably use Cloudflare and other caching tools to help so that most of them get cached for a maximum of 24 hours, but I can't completely rely on that.
tl;dr:
Two main questions:
What's the fastest way to generate avatars on the web (right now I'm using PHP)?
What are some good server specs for around 100+ daily unique clients (at minimum) using this server for generating these avatars?
Edit: Another question, which webserver could process more requests for this? Right now I'm using Apache for this server, but my other servers are using nginx for other API things (like logging users in, getting info, etc).
IMHO, language is not the bottleneck. PHP is fast enough for real-time small images processing. You just need right algorithm. Also, check out bytecode caching engines such as APC, or XCache, or even HHVM. They can significantly improve PHP performance.
I think, any VPS can do the job until you have >20 concurrent requests. The more clients use service at the same time the more RAM you need. You can easily determine your script memory needs and other performance info by using profiler, such as XHProf.
Nginx or Lighttpd in FastCGI mode use less RAM than Apache http server and they can handle more concurrent connections. But is's not important until you have many concurrent connections.
Yes, PHP is can do this job fast and flexible(example generate.php?size=32)
I know only German webspaces, but they have also an English interface. www.nitrado.net
I'm trying to set up a page where users can perform different actions on a webpage while chatting with me. I need to be able to have a live view of a particular DIV on the user's page that has tabs. When I click a tab, it should update on their screen and when they click a tab, it should reflect on my screen.
Finding a chat script was easy enough, but I'm struggling to locate on Google and Stack Overflow a basic script or code snippets to acheive this. Perhaps I'm not using the correct terms. Could someone please point me in the right direction?
I think what you need is socket.io. It's really easy to use: http://socket.io/#how-to-use
There are many ways to hack this into working, but, if you want a standardized way of doing it, use the Bayeux protocol. Way that this kind of communication is done by gmail, facebook and so on is via an implementation of cometd (cometd.org). There is a lot of reference material for implementing this setup on the net.
By going this route, it's going to be a two part problem: (1) setup the environment to allow for cometd interaction
This could basically be 0 work, provided that your remote host gives you ability to run daemon scripts ex: infinite PHP scripts.
(2) write the code that will sync clients with server. This will be the low end part where you read the div, and make broadcast-level communication to all clients about it.
A good fully operational example is this How to implement COMET with PHP article.
I'm looking for a way to make a web server cache and provide resized images from another remote server.
Let's say there's Site A located somewhere in Africa. On Site A are JPEG images that are refreshed every five minutes (they're webcams). If you visit Site A from the US, the images take quite a while to load since the server is in Africa.
I have Site B. I would like Site B to display the four images from Site A, but I would like them to be served from a server here in the US (which is also where Site B is hosted). That way, they'll, of course, load much quicker.
I'm not familiar with script creation. I tried a few PHP scripts from CodeCanyon and the concept works, but there always seems to be a few minor bugs that cause the entire system to fail.
They work by providing the remote image URL after the local site URL (i.e. http://www.SiteB.com/image_cacher.php?=http://www.SiteA.com/image1.jpg). That's exactly what I want to do.
I'd like the cached images to be stored on the Site B server in a folder called "cache." That way, I can use a cron job to automatically delete the cached images every five minutes; the same frequency the webcam images are updated.
I've solved the cron job issue though, so my only dilemma now is creating some type of script (preferably PHP) that can achieve this.
There are many similar questions like this here, but they're all minutely different and I unfortunately haven't been able to find anything that can perform this task.
Thanks!
I have read a few good articles about coding a socket server but thought I would ask here to see if there is any further knowledge/ideas about what I actually need.
I run multiple websites for clients all running off the same server, connecting to the same DB etc. Each client website has a form where users can submit their details for services we offer. These users are spread out across the world but what I am wanting to build is a monitoring system where my interface displays the users IP address, client website they are on, the page they are on etc. From the IP I will do a country/state look up (I know its not 100% accurate but close enough is good).
I would like the visiting site to send a packet to the socket server which in turns sends the output information to my screen in real time (after I perform some actions). I guess you could say I am building a mini NOC to monitor website activity. I would also like the output information to be most recent activity at top of screen but also show a scroll bar to view all activity.
Are sockets the best mechanism for this system? Any other suggestions or tutorials on how to achieve the outcome?
Many thanks.
Before you begin down this road, have you checked out the realtime part of Google Analytics? It does most of what you are looking for.
When someone is visiting your site, you aren't typically going to have a persistent connection. I'd suggest that rather than creating one, parse your server logs or store user information in a database, and query for the last x minutes of visitors.
For updating the viewing page that you are on in realtime, Web Sockets are best for this if you need very fast response time, but are currently quite the hassle to do in PHP. In addition, browser support isn't very wide. If you insist on using PHP, I'd recommend polling over AJAX. Otherwise, look into using Node.JS with Socket.IO. Socket.IO wraps up a lot of similar methods to web sockets to get the same effect with little effort. Still use PHP for your application... just use the Node.JS/Socket.IO part for your monitor interface.
Finally, I'd suggest questioning again why you might want this. You can spend a lot of time on a project like this, and the truth is that your analytics data over time is far more valuable than a snapshot when you are looking at it.
We are switching web hosts, and I have been asked to find out how many concurrent users the Magento-based websites have in order to estimate the appropriate hardware.
How can I find this information out?
The webserver is lightspeed (like apache) and it is PHP-based.
Other information that may (or may not) be helpful is that the sites are currently hosted on a shared hosting solution, so I don't think I can install any monitoring software.
I have noticed that Magento has a built in report that may be similar to this... Admin -> Customers -> Online Customers. But I have a feeling this report isn't really what the new web host is looking for.
Should this question be posted in another Stack Exchange site?
Sign up for Google Analytics at http://www.google.com/analytics/. They will provide you with a tracking code to paste into the html of your site. Insert that into your header template. It may take half a day or longer for the stats to accumulate.
Then take a look at your peak hourly stats. Click visitors then switch the graph to hourly and take a look at the hour with the max visits. That will help you approximate the amount of traffic your new host will need to accomodate. Also take a look at pageviews since that's also an important metric. Visits and pageviews are not the same as concurrent users but it should put you in the right direction.
Are you moving to a dedicated or at least dedicated resource vps? If you're currently on a shared host, it's really hard to get a true sense for what type of hardware you are going to need (I'm assuming the reason you are switching is because of performance problems). I'd suggest starting with a basic dedicated server and then either going up or down from there based on your results.
You could try the m1.small instance at Amazon EC2 which will cost you about $70/month and you'll be able to host multiple sites on there. Of course you'll have to manage the server yourself.
Run some analysis on your server logs. Or if there are no logs available to you set up google analytics, let it run for a while and get a good indication of traffic levels.