This is quite trivial if you're using something like PHP with Apache. You could implement the count manually on a per user basis using cookies (optimally), or if they have cookies disabled use something clever. This type of stuff belongs in a PHP script.
It seems that with a setup like yours, you probably have a user/password hash for authentication, so when they log in, log it. Every time they start a new session, log it. If they reach 5000 sessions, return a 401 error or something explaining that they have exceeded their per-month allotment of views.
If this truly is on a per-user basis, a server-side script would make the most sense. You don't even need to have a database, a simple text file will do the trick.
I'm pretty sure that a PHP script can access what host it is being accessed on (just look at the URL).
/proc/sys/net/core/somaxconn/for concurrent connections andproc/sys/net/core/netdev_max_backlogfor packet queue. – tjameson Apr 4 '11 at 17:13