{"id":1497,"date":"2009-03-30T21:29:26","date_gmt":"2009-03-30T21:29:26","guid":{"rendered":"http:\/\/wiki.davelevy.info\/?p=1497"},"modified":"2024-02-22T16:48:34","modified_gmt":"2024-02-22T16:48:34","slug":"short-urls","status":"publish","type":"post","link":"https:\/\/davelevy.info\/wiki\/short-urls\/","title":{"rendered":"Short URL&#8217;s"},"content":{"rendered":"<div>\n<p>Microblogging makes this important. There are a bunch, but I prefer http:\/\/is.gd because its five characters long.<\/p>\n<h3>Services<\/h3>\n<p>Other&#8217;s I&#8217;ve found and used include<\/p>\n<ul>\n<li>http:\/\/tinyurl.com\/<\/li>\n<li><a href=\"http:\/\/bit.ly\/\">http:\/\/bit.ly\/<\/a><\/li>\n<\/ul>\n<p>A number of people publish top 10 lists, you can use google to find them.<\/p>\n<\/div>\n<div><\/div>\n<div>\n<h3>Problem definition<\/h3>\n<p>I am interested in writing or implementing a url-shortener, for use inside the firewall, or implementing through an API. It seems quite simple until you consider performance at scale. My first thought was to use a database with an identifier\/sequence data type as the key to the hashing algorithm, since its best to keep a record of the URL&#8217;s issued so if people ask twice for the same url it can be reused.<\/p>\n<p>The second part is resolving the URL on request. Is this just an apache solution with a <b>very<\/b> large redirect file?<\/p>\n<h3>Some research<\/h3>\n<p>I used <a href=\"http:\/\/www.google.co.uk\/search?hl=en&amp;client=firefox-a&amp;rls=org.mozilla:en-GB:official&amp;hs=9Lh&amp;ei=mU_BSd6BBZmzjAfUzPww&amp;sa=X&amp;oi=spell&amp;resnum=0&amp;ct=result&amp;cd=1&amp;q=url+shortener+howto&amp;spell=1\">google: url shortner howto<\/a>, to see what it came up with.<\/p>\n<p>Two interesting finds included<\/p>\n<ul>\n<li><a href=\"https:\/\/web.archive.org\/web\/20110811062006\/http:\/\/blog.cullect.com:80\/\">http:\/\/blog.cullect.com<\/a>&#8216;s article on how to build a url shortener, but actually its about using their SaaS<\/li>\n<\/ul>\n<h3>Ideas<\/h3>\n<p>Idea No 1 was to use a database identifier type and hash it, I was going to investigate if we could use a web server redirection file, or if I&#8217;d have to write something using a db retrieval. However both these the database transactions introduce serial bottlenecks and inhibit scalability.<\/p>\n<p>So can pre-allocate the sh.urls in blocks , and allocate them using hadoop? Is hadoop a sensible solution for &#8220;find me next unused&#8221;, or perhaps it doesn&#8217;t matter; its just find me one unused slot?<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Microblogging makes this important. There are a bunch, but I prefer http:\/\/is.gd because its five characters long. Services Other&#8217;s I&#8217;ve found and used include http:\/\/tinyurl.com\/ http:\/\/bit.ly\/ A number of people publish top 10 lists, you can use google to find them. Problem definition I am interested in writing or implementing a url-shortener, for use inside&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_share_on_mastodon":"0"},"categories":[3],"tags":[77,491,911],"class_list":["post-1497","post","type-post","status-publish","format-standard","hentry","category-technology","tag-apache","tag-short-url","tag-technology"],"share_on_mastodon":{"url":"","error":""},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/1497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/comments?post=1497"}],"version-history":[{"count":8,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/1497\/revisions"}],"predecessor-version":[{"id":10514,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/posts\/1497\/revisions\/10514"}],"wp:attachment":[{"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/media?parent=1497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/categories?post=1497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/davelevy.info\/wiki\/wp-json\/wp\/v2\/tags?post=1497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}