Slide 1

Slide 1 text

Hello & welcome to my talk. @jewelia

Slide 2

Slide 2 text

Julia Grace @jewelia ! Head of Engineering at Tindie ! ! ! !

Slide 3

Slide 3 text

Location on the Internet @jewelia

Slide 4

Slide 4 text

IP to location mapping @jewelia

Slide 5

Slide 5 text

Tindie isn’t just in US @jewelia

Slide 6

Slide 6 text

Buyers in 60 Countries Sellers in 40 Countries @jewelia

Slide 7

Slide 7 text

We had a problem. ! ! Hot Mess

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

That seems a little 90s

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Story of how we did it. @jewelia

Slide 14

Slide 14 text

Step 0: Avoid the problem @jewelia

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

We had to fix this. @jewelia

Slide 17

Slide 17 text

Only show shipping rates for the user’s country. @jewelia

Slide 18

Slide 18 text

How? @jewelia

Slide 19

Slide 19 text

We had some crazy ideas. @jewelia

Slide 20

Slide 20 text

No HTML5 Geolocation. @jewelia

Slide 21

Slide 21 text

IPinfoDB ! “Over 99.5% on a country level and around 60% on a city level for the US within a 25 mile radius.” ! @jewelia

Slide 22

Slide 22 text

Client side or server side? @jewelia

Slide 23

Slide 23 text

Server side! @jewelia

Slide 24

Slide 24 text

Middleware @jewelia

Slide 25

Slide 25 text

Dancing with the devil ! Set the country in the session based of X_FORWARDED_FOR ! If there is no country in session, then query IPinfoDB once. Put very strict timeouts and no retries on this. ! If the query fails then don’t show country specific info. ! @jewelia

Slide 26

Slide 26 text

Pros ! We have country info! ! Could cache the IP/Country info in Redis for fast future lookups. ! How often should we update? How often does IP/Country data change? @jewelia

Slide 27

Slide 27 text

Cons ! We are explicitly introducing latency. ! User pays a latency penalty on first visit; this could leave a bad first impression. ! @jewelia

Slide 28

Slide 28 text

When you start using the word penalty to talk about a feature, something is very wrong. @jewelia

Slide 29

Slide 29 text

We deployed it! @jewelia

Slide 30

Slide 30 text

And it didn’t work. @jewelia

Slide 31

Slide 31 text

10.x.x.x @jewelia

Slide 32

Slide 32 text

This is what happens when dev and prod aren’t the same. @jewelia

Slide 33

Slide 33 text

Crawlers don’t have sessions. @jewelia

Slide 34

Slide 34 text

Ran this in prod for a few weeks. @jewelia

Slide 35

Slide 35 text

Client side! @jewelia

Slide 36

Slide 36 text

Load in so it won’t block the other content on page from loading. @jewelia

Slide 37

Slide 37 text

Pros ! Client side is great for IP based rate-limiting and throttling! ! (If all of your users are coming from different IPs, which most are, versus your server which likely has 1 IP) @jewelia

Slide 38

Slide 38 text

Cons ! IPinfoDB has no https based endpoint. ! ! @jewelia

Slide 39

Slide 39 text

This is what happens when dev and prod aren’t the same. @jewelia

Slide 40

Slide 40 text

Server side! @jewelia

Slide 41

Slide 41 text

In nginx we trust. @jewelia

Slide 42

Slide 42 text

HttpGeoipModule @jewelia

Slide 43

Slide 43 text

Pros ! Uses MaxMind GeoIP database. ! Unix package (available via apt-get or aptitude). ! Updated nightly! ! $geoip_country_code — two-letter country code, for example, "RU", "US". ! ! Nginx caches all supplied databases in memory. The country database is small, roughly 1.4M @jewelia

Slide 44

Slide 44 text

Cons ! Unix experience and server access needed. @jewelia

Slide 45

Slide 45 text

@jewelia

Slide 46

Slide 46 text

Thanks! @jewelia