Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: blocking IPs

by l3nz (Friar)
on Jan 27, 2004 at 08:08 UTC ( #324373=note: print w/replies, xml ) Need Help??


in reply to blocking IPs

Even if you consider IP blocking the way to go, beware of using flat files for your database. I don't know how big your site gets, but please notice that reparsing a single big file thousand and thousand times is a costly operation. Also, writing the same file by different processes at once might result in broken data under heavy load or transient opening errors. It would be much better if you had a database.

If you don't want to use a database, I'd say go for a number of files, not just a single big one. You could use a number of files like ipblock_001.txt, ipblock_002.txt and so on, where the number is the least significant byte in the IP address. This way, IP address entries should be evenly distribuited among multiple files and you'll have less concurrency on the same file and much shorter access times. You should also prepare a job to 'purge' files of stale IP entries, unless you want to rewrite each file from scratch on every write access.

A format for each file could be:
ip-address picture-code timestamp-vote
I'll assume you have the votes also in another file, as the content of this files will be rotated on an hourly basis. When a vote is cast, you read this file and determine whether you have a vote for this picture in the last hour; if you do, you print an error message; if you don't, you add an entry.

Hope this helps

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://324373]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2022-08-07 19:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?