{"id":246,"date":"2011-03-30T18:57:17","date_gmt":"2011-03-30T16:57:17","guid":{"rendered":"http:\/\/blog.railsware.com\/?p=246"},"modified":"2021-08-12T17:14:03","modified_gmt":"2021-08-12T14:14:03","slug":"url-shortening-how-we-do-it-2","status":"publish","type":"post","link":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/","title":{"rendered":"URL shortening. How we do it."},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We didn\u2019t want to reinvent the wheel \u2013 so we have been using popular external services for this purpose.<br>\nHowever, by producing a somewhat heavy load on the service, we\u2019ve run into some well known problems: request limit per hour, external service timeouts, service downtime, and other nasty things.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The shortening service was used as a part of a few business tools.<br>\nShortening was done both in the background, meaning it had to be highly reliable, and in the foreground, necessitating speed of process.<br>\nAlso, when shortening was finished, the new, truncated URLs had to be accessible for the consumers.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">From time to time, we encountered all of the issues, resulting in slow, unreliable, inaccessible shortened URLs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So, we had to do something.<br>\nThe solution should meet the following requirements:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1) In order to maintain high accessibility, the new method would require the ability to do a full fallback, just in case the main service went down completely;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2) There would have to be a visual consistency in the shortened URLs; and<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3) It must be easy to develop, cheap to host and take zero support efforts.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The popular shortener service was set to use a <strong>custom domain<\/strong> xxx.aa, so that we have control over the accessibility.<br>\nThe xxx.aa DNS TTL would be set to 5 minutes, so we can switch it any time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A very simple <strong>backup shortener service<\/strong> was to be developed and hosted on a xxx.bb domain for visual similarity.<br>\nIt wouldn&#8217;t contain any extra functionality: just shorten a long url and follow a shortened url.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A <strong>shortener client<\/strong> was to be developed to automatically balance between services, when the url creation wouldn&#8217;t work.<br>\nFirst, it would try the external service and if it doesn&#8217;t work &#8211; would switch to the backup service.<br>\nFor a quick response time, it would perform just one shortening try when called from the foreground, but would perform multiple tries, with incremental back-off, from the background, to use as much external service shortening as possible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>shortener client<\/strong> would also contain a caching mechanism to reduce duplicated requests to the external service, thus saving limits usage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We would monitor the external service and in case it goes down, the xxx.aa domain had to be switched to the <strong>backup shortener service<\/strong>.<br>\nThe <strong>backup shortener service<\/strong> would use the cached data to serve all the external services shortened urls, for the accessibility purpose.<\/p>\n\n\n\n<div id=\"_mcePaste\">We rolled our sleeves and got to work.<\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Backup shortener service<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To make sure that both urls are visually similar, we were running a custom domain (xxx.aa) on one of the external shortener while running our own backup shortener on xxx.bb. So when the backup model took place &#8211; the difference was not really noticeable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Results caching and the external service &#8220;bad&#8221; days<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Initially memcached was used for caching.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Several hardware upgrades helped us to switch to Redis quickly.<br>\nThat&#8217;s because the second one has permanent storage feature while the first one &#8220;forgets&#8221; everything after server restart.<br>\nThis switch helps us to keep external service away from overloads produced by us in such cases.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On the &#8220;bad&#8221; days, or just times when we had a big volume of urls to shorten, we had near 50\/50 conversions between external service and our backup.<br>\nBut overall, the backup service was only used in less than 1% cases.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Backup shortener service architecture<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Architecture of our solution is as simple as possible. At the time of its creation we&#8217;ve used Rails 2 and Redis as a storage of short URLs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We have two controllers &#8211; <em>shortener<\/em> and <em>redirector<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Shortener<\/em> takes incoming parameters, parses them and tries to create short URL.<br>\nWe used a simple hashing algorithm (see below).<br>\nOutput is given in JSON format including status code, message, if needed, and a bunch of other stuff which includes the shortened url itself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Redirector <\/em>runs as Rails Metal application. All it does is searching for short url hash taken from incoming parameters and sending a redirect request to the original URL. Nothing more, nothing less.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Shortener client<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The client was created as a gem, so it could be reused in multiple projects.<br>\nThe minor balancing was done automatically from the code using something like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> services.each_with_index do |service, i| next_service = services[i+1] begin return try_get_service_short_url(long_url, service, options) rescue ShortenerOutOfTriesError => e # out of tries can be logged in a file here end end def try_get_service_short_url(long_url, service, options) options = {:incremental_backoff => false, :retry_count => 3, :timeout => config.timeout}.merge(options) timeout = options[:timeout].to_i retry_count = options[:retry_count] incremental_backoff = options[:incremental_backoff] tries = 0 errors = [] begin return get_service_short_url(long_url, service, timeout) rescue ShortenerValidationError => e # give long url back if validation failed raise ShortenerValidationError, e.message if e.instance_of?(ShortenerValidationError) rescue Exception => e # log raise ShortenerOutOfTriesError.new(e.message, errors) if e.instance_of?(ShortenerHourlyLimitError) raise ShortenerOutOfTriesError.new(\"Retries count exceeded (#{retry_count})\", errors) if (tries += 1) > retry_count sleep(2**tries) if tries > 1 &amp;&amp; incremental_backoff retry end end <\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The get_service_short_url method implements remote requests to each service with response parsing.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hashing algorithm<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For consistency purpose we would use the popular Base62 encoded string of 6 characters length.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After trying several approaches we came to the current one finally. It is based on using MD5 hashing of incoming string.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> url36 = Digest::MD5.hexdigest(long_url+\"in salt we trust\").slice(0..6) <\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here we&#8217;re taking string, adding salt, converting it to MD5 hash and taking the first 7 chars.<br>\nWhy just 7, you&#8217;ll wonder? It&#8217;s simple: 7 chars of Base62 is enough for 6 chars of Base36. 36^7 &gt; 62^6.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Sample code to convert Base36 to Base10 and then to Base62<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"> base62 = ['0'..'9','A'..'Z','a'..'z'].map{|a| a.to_a}.flatten base36 = {};['0'..'9','a'..'z'].map{|range| range.to_a}.flatten.each_with_index{|char, position| base36[char] = position} url10 = 0; url62 = \"\" # convert to base10 url36.reverse.chars.to_a.each_with_index { |c,i| url10 += base36[c] * (36 ** i)} # convert to base62 6.times{|i| url62 &lt;&lt; base62[url10 % 62]; url10 = url10 \/ 62} <\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Great!<br>\nBut what if a produced result is already used by previous conversion? You&#8217;ll have to repeat the process.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ve decided to add trailing &#8220;_&#8221; sign to the original URL for the conversion purposes to produce different result.<br>\nThe problem will occur when most of Base62 variants will be used, so you&#8217;ll have to be well prepared to deal with eternal conversion cycle :), but as it&#8217;s a backup service and is used only for less than 1% cases &#8211; it will take a while.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After implementing all of the above &#8211; we&#8217;ve never had any issues.<br>\nAt first, we have also implemented some monitoring to see how often would the balancing take place, checking few cases a week if it works.<br>\nBut finally, it all got stable and we never look into the solution again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By the time the external service got more stable and don&#8217;t fall down as often as they did earlier, especially with the caching solution in place.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But if it do fall, our balancing and the backup service is right in the place doing it&#8217;s job.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good. We didn\u2019t want to reinvent the wheel \u2013 so we have been using popular external&#8230;<\/p>\n","protected":false},"author":20,"featured_media":9469,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[3],"tags":[],"coauthors":["Igor Antonyuk"],"class_list":["post-246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development"],"acf":[],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.\" \/>\n\t<meta name=\"robots\" content=\"max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n\t<meta name=\"author\" content=\"Igor Antonyuk\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"| Blog on Engineering, Product Management, Transparency, Culture and many more...\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"URL shortening. How we do it. | Railsware Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/URL-shortening.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/URL-shortening.png\" \/>\n\t\t<meta property=\"og:image:width\" content=\"360\" \/>\n\t\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2011-03-30T16:57:17+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2021-08-12T14:14:03+00:00\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#article\",\"name\":\"URL shortening. How we do it. | Railsware Blog\",\"headline\":\"URL shortening. How we do it.\",\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/igor-antonyuk\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/URL-shortening.png\",\"width\":360,\"height\":360,\"caption\":\"URL shortening\"},\"datePublished\":\"2011-03-30T18:57:17+03:00\",\"dateModified\":\"2021-08-12T17:14:03+03:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#webpage\"},\"articleSection\":\"Engineering\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"position\":2,\"name\":\"Engineering\",\"item\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#listItem\",\"name\":\"URL shortening. How we do it.\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#listItem\",\"position\":3,\"name\":\"URL shortening. How we do it.\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/category\\\/development\\\/#listItem\",\"name\":\"Engineering\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/11\\\/Logo-circle.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#organizationLogo\",\"width\":3137,\"height\":1054,\"caption\":\"Railsware logo\"},\"image\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#organizationLogo\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/igor-antonyuk\\\/#author\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/igor-antonyuk\\\/\",\"name\":\"Igor Antonyuk\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#authorImage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/06\\\/author-image-default-96x96.jpg\",\"width\":96,\"height\":96,\"caption\":\"Igor Antonyuk\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#webpage\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/\",\"name\":\"URL shortening. How we do it. | Railsware Blog\",\"description\":\"The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/igor-antonyuk\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/author\\\/igor-antonyuk\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/12\\\/URL-shortening.png\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#mainImage\",\"width\":360,\"height\":360,\"caption\":\"URL shortening\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/url-shortening-how-we-do-it-2\\\/#mainImage\"},\"datePublished\":\"2011-03-30T18:57:17+03:00\",\"dateModified\":\"2021-08-12T17:14:03+03:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/railsware.com\\\/blog\\\/\",\"description\":\"Blog on Engineering, Product Management, Transparency, Culture and many more...\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/railsware.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"URL shortening. How we do it. | Railsware Blog","description":"The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.","canonical_url":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/","robots":"max-snippet:-1, max-image-preview:large, max-video-preview:-1","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#article","name":"URL shortening. How we do it. | Railsware Blog","headline":"URL shortening. How we do it.","author":{"@id":"https:\/\/railsware.com\/blog\/author\/igor-antonyuk\/#author"},"publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/URL-shortening.png","width":360,"height":360,"caption":"URL shortening"},"datePublished":"2011-03-30T18:57:17+03:00","dateModified":"2021-08-12T17:14:03+03:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#webpage"},"isPartOf":{"@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#webpage"},"articleSection":"Engineering"},{"@type":"BreadcrumbList","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/railsware.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","position":2,"name":"Engineering","item":"https:\/\/railsware.com\/blog\/category\/development\/","nextItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#listItem","name":"URL shortening. How we do it."},"previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#listItem","position":3,"name":"URL shortening. How we do it.","previousItem":{"@type":"ListItem","@id":"https:\/\/railsware.com\/blog\/category\/development\/#listItem","name":"Engineering"}}]},{"@type":"Organization","@id":"https:\/\/railsware.com\/blog\/#organization","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","url":"https:\/\/railsware.com\/blog\/","logo":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2020\/11\/Logo-circle.png","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#organizationLogo","width":3137,"height":1054,"caption":"Railsware logo"},"image":{"@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#organizationLogo"}},{"@type":"Person","@id":"https:\/\/railsware.com\/blog\/author\/igor-antonyuk\/#author","url":"https:\/\/railsware.com\/blog\/author\/igor-antonyuk\/","name":"Igor Antonyuk","image":{"@type":"ImageObject","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#authorImage","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2021\/06\/author-image-default-96x96.jpg","width":96,"height":96,"caption":"Igor Antonyuk"}},{"@type":"WebPage","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#webpage","url":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/","name":"URL shortening. How we do it. | Railsware Blog","description":"The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/railsware.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#breadcrumblist"},"author":{"@id":"https:\/\/railsware.com\/blog\/author\/igor-antonyuk\/#author"},"creator":{"@id":"https:\/\/railsware.com\/blog\/author\/igor-antonyuk\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/URL-shortening.png","@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#mainImage","width":360,"height":360,"caption":"URL shortening"},"primaryImageOfPage":{"@id":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/#mainImage"},"datePublished":"2011-03-30T18:57:17+03:00","dateModified":"2021-08-12T17:14:03+03:00"},{"@type":"WebSite","@id":"https:\/\/railsware.com\/blog\/#website","url":"https:\/\/railsware.com\/blog\/","description":"Blog on Engineering, Product Management, Transparency, Culture and many more...","inLanguage":"en-US","publisher":{"@id":"https:\/\/railsware.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"| Blog on Engineering, Product Management, Transparency, Culture and many more...","og:type":"article","og:title":"URL shortening. How we do it. | Railsware Blog","og:description":"The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.","og:url":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/","og:image":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/URL-shortening.png","og:image:secure_url":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/URL-shortening.png","og:image:width":360,"og:image:height":360,"article:published_time":"2011-03-30T16:57:17+00:00","article:modified_time":"2021-08-12T14:14:03+00:00"},"aioseo_meta_data":{"post_id":"246","title":"URL shortening. How we do it. | Railsware Blog","description":"The growing demand to share content through the different social networks has rapidly led us to the need to shorten URLs in order to free space within a post (Twitter is a good example here) and it actually looks good.","keywords":[{"label":"URL shortening","value":"URL shortening"},{"label":"approach","value":"approach"},{"label":"productivity","value":"productivity"}],"keyphrases":{"focus":[],"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":{"id":"aioseo-article-6385f5afd7416","slug":"article","graphName":"Article","label":"Article","properties":{"type":"BlogPosting","name":"#post_title","headline":"#post_title","description":"#post_excerpt","image":"","keywords":"","author":{"name":"#author_name","url":"#author_url"},"dates":{"include":true,"datePublished":"","dateModified":""}}},"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":"{\"article\":{\"articleType\":\"BlogPosting\"},\"course\":{\"name\":\"\",\"description\":\"\",\"provider\":\"\"},\"faq\":{\"pages\":[]},\"product\":{\"reviews\":[]},\"recipe\":{\"ingredients\":[],\"instructions\":[],\"keywords\":[]},\"software\":{\"reviews\":[],\"operatingSystems\":[]},\"webPage\":{\"webPageType\":\"WebPage\"}}","pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","location":null,"local_seo":{"locations":{"business":{"name":"","businessType":"","image":"","areaServed":"","urls":{"website":"","aboutPage":"","contactPage":""},"address":{"streetLine1":"","streetLine2":"","zipCode":"","city":"","state":"","country":"","addressFormat":"#streetLineOne\n#streetLineTwo\n#city, #state #zipCode"},"contact":{"email":"","phone":"","phoneFormatted":"","fax":"","faxFormatted":""},"ids":{"vat":"","tax":"","chamberOfCommerce":""},"payment":{"priceRange":"","currenciesAccepted":"","methods":""}}},"openingHours":{"useDefaults":true,"show":true,"alwaysOpen":false,"use24hFormat":false,"timezone":"","labels":{"closed":"","alwaysOpen":""},"days":{"monday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"tuesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"wednesday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"thursday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"friday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"saturday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"},"sunday":{"open24h":false,"closed":false,"openTime":"09:00","closeTime":"17:00"}}}},"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2021-01-04 12:44:08","updated":"2025-09-26 11:12:39","seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/railsware.com\/blog\/category\/development\/\" title=\"Engineering\">Engineering<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tURL shortening. How we do it.\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/railsware.com\/blog"},{"label":"Engineering","link":"https:\/\/railsware.com\/blog\/category\/development\/"},{"label":"URL shortening. How we do it.","link":"https:\/\/railsware.com\/blog\/url-shortening-how-we-do-it-2\/"}],"categories_data":[{"name":"Engineering","link":"https:\/\/railsware.com\/blog?category=development"}],"post_thumbnails":"https:\/\/railsware.com\/blog\/wp-content\/uploads\/2017\/12\/URL-shortening.png","article_background":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/comments?post=246"}],"version-history":[{"count":31,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/246\/revisions"}],"predecessor-version":[{"id":14001,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/posts\/246\/revisions\/14001"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media\/9469"}],"wp:attachment":[{"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/media?parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/categories?post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/tags?post=246"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/railsware.com\/blog\/wp-json\/wp\/v2\/coauthors?post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}