RE: ip-to-country - summary
| From: | Divyank Turakhia | Date: | Fri, 25 Apr 2003 21:27:43 +0000 |
| Subject: | RE: ip-to-country - summary | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-17082@lists.php.net to get a copy of this message | ||
This is a good idea - I have made a note of it for the automatic
redirection summary.
This is also a good idea for automatically pushing the file from the
closest mirror when a user chooses to download a particular file. So
instead of showing the user a list of mirrors, if we can test the mirror
by downloading 1-2 kb of data from it, then we can directly display a
message saying something like "Downloading from the nearest mirror ..."
and push the user the link so that the download starts automatically.
The issue that I see with the above, is that we cannot guarantee, that
the file will actually download faster. There is a chance that the ISP
hosting the mirror in the same country does not have peering
relationships with the visitors ISP. This would mean, that the data
would have to be travel a real long way to reach the end user. I will
add this to the endless list of issues with automatic redirection /
downloading.
Please note: We are not planning to implement ANY of the above as of
now, before anyone starts pouncing on me for this :o), due to obvious
issues. But it would be very interesting if we can achieve a perfect
deployment of this.
- Div
> -----Original Message-----
> From: Jacques Marneweck [mailto:jacques@ataris.co.za]
> Sent: Saturday, April 26, 2003 1:10 AM
> To: Gabor Hojtsy; Divyank Turakhia; php-mirrors@lists.php.net
> Cc: jimw@php.net; imajes@php.net; 'James Cox'
> Subject: RE: ip-to-country - summary
>
>
> Hi,
>
> I was taking a peek at doing stuff kief stuff when doing a
> /get/file/from/mirror goodie we can open a connection to the
> remote server the user wants to pull the file from and check
> it the file exists read say 1024/2048 or however many bytes,
> check the status code. I do something similar with my
> implementation to Colin's works stuff and to a couple other
> sites that I use for work. This would add a slight 1 sec or
> so delay but it's prob worth it?
>
> Regards
> --jm
>
> > -----Original Message-----
> > From: Gabor Hojtsy [mailto:gabor@hojtsy.hu]
> > Sent: Friday, April 25, 2003 6:17 PM
> > To: Divyank Turakhia; php-mirrors@lists.php.net
> > Cc: jimw@php.net; imajes@php.net; 'James Cox'
> > Subject: Re: ip-to-country - summary
> >
> >
> > > ) We have no issue in using the Directi ip-to-country
> > database. No one
> > > seems to have any objection with this yet, so I am assuming
> > that we are
> > > going ahead with this.
> >
> > OK.
> >
> > > ) We are going to use the database initially for the following:
> > > ) To display events from the visitors country on top
> >
> > This will be handled differently (probably we will make the
> events in
> > the user's country bold), due to caching reasons. I'll explain
> > this when we get
> > there...
> >
> > > ) To display the visitors country on top in the "mirror
> > sites" page
> > > ) To display the visitors country on top in the download pages
> >
> > Yep.
> >
> > > ) Automatic Redirection is something that we want to do
> once we have
> > > discussed solutions to tackle all the possible situations
> > that arise out
> > > of the same. There are quite a few "situations" :o) - so
> > this may take a
> > > little time.
> >
> > Well, whether we want it or not is not to be declared now.
> It would be
> > a nice thing, but we cannot see correct methods to achive it. But it
> > is for later,
> > not our current focus...
> >
> > > ) The php website is going to download the ip-to-country
> > database from
> > > the directi website in the format that we all mutually
> come up with
> > > using a cron. This format is the exact format that the
> php website
> > > needs.
> >
> > Yep.
> >
> > > ) Distribution of the db to mirrors and related sites will happen
> > > through rsync
> >
> > Yep.
> >
> > > Our next step now is to start building the format of the db
> > by writing
> > > test scripts. Let me know if any one need any inputs from
> my end for
> > > this.
> >
> > Well, I was unable to come up with anything better, then my
> indexable
> > text file idea. What we need with this format:
> >
> > - three fields: iprange from and to and three letter countrycode
> > - have all fields padded to a fixed length (actually only
> the first
> > two
> > are related, and they should be padded with zeros added to the
> > left to let PHP recognized them as numbers, if they need
> to act in
> > a comparision)
> > - no char to separate the fields. This is not needed because of the
> > fixed width nature of the data
> > - \n (one byte) linending
> >
> > This way, one record will be (2*ipnumber_length+3+1) bytes.
> So we can
> > build up an index for the IP numbers. This would mean that
> we need to
> > define a step,
> > with which we index the IP list. So something like:
> >
> > $where_to_start_for_ip_search = array(
> > 0 => 0,
> > 10000 => 15,
> > 20000 => 23,
> > [...]
> > );
> >
> > This is a mapping between where (at what record) to start to search
> > for an IP above that number. Then we can fseek() to that
> position, as
> > we know the fixed
> > size of records. From there we can start a normal linear
> > search, that would
> > probably be sufficient.
> >
> > Then when we find the right range and country, we set it in
> a cookie
> > for the user, so it stays there, and we won't need to find out the
> > country again.
> >
> > Divyank, I would like to ask you to create an output format
> like this,
> > so we can start to write the script on our end to receive the file,
> > process it to
> > create the index, and deploy it to the mirror sites. Except
> > if anyone has any
> > objections to the above method, or can suggest a better one
> > ;) Don't be
> > afraid of suggesting anything revolutionary ;)
> >
> > Goba
> >
>
>