0

I have a domain (let's call it one.com) that contains:

  • A website
  • A MySQL DB + a REST API service written in PHP to access the data

The API service is used by a mobile platform that calls it through the url one.com/api. The contents that come in/out the API are simply JSON data.

Everything is hosted by a famous service which guarantees a very generous bandwidth. Anyway, we never had problems reaching the limit since the amount of transferred data and the usage of the app are relatively low.

For a couple of reasons, we decided to move the entire DB and API infrastructure to another domain, call it two.com, with its API endpoint two.com/api, leaving only the website. For this, the requests that the mobile app sends to one.com/api must be redirected to the new two.com/api. We successfully did that using the Apache's htaccess "mod_rewrite" way.

Now that the generous hosting plain for one.com became too much for just the website, we are going to downgrade it to a cheaper shared hosting, but this time we read that "an approximated load of 10.000 visits each month is suitable for this shared plan".

It's obviously a reference, and it should be fine for our website, but what about the REST API service? I mean, does the one.com bandwidth will be still affected by calls to one.com -> two.com requests, introducing a possible bottleneck if the usage of our app will increase in the future?

TheUnexpected
  • 131
  • 1
  • 1
  • 6
  • 1
    In your questions please refrain from using random domain names and use either your *own domain* or one of the [RFC 6761](https://tools.ietf.org/html/rfc6761#section-6.5) reserved domain names such as `example.com`, `example.org` or similar . Please refer to [this Q&A](http://meta.serverfault.com/q/963/37681) for our recommendations with regards to how and what (not) to obfuscate in your questions. – HBruijn Oct 05 '16 at 19:08

1 Answers1

1

I'm assuming you are speaking about a 301 redirect (moved permanently).

Your one.com server will still incur some bandwidth usage, but not as much as before the redirect. A 301 redirect just answers the client with a response header telling them to request some new URL instead. It doesn't send the actual content of the new URL. So you will only be using minimal bandwidth to send that small response header, however depending on how popular your api is, it can still mount up. It also depends on whether your app is smart enough to learn that 301 means 301, not 302, and remember to send future requests to the new URL.

It would be much better to update your app to point to the new URL in either case.

James Swift
  • 154
  • 1
  • 14
  • Thanks. It's clear to me that 30x redirects are a lightweight, temporary solution. Just to be clear, what if someone use the mod_rewrite method instead? For example `RewriteRule ^/api/(.+)/?$ http://two.com/api/$1 [L,QSA,P]` (it's a simplified case, but I hope you got the point). Being not a "genuine" redirect, is the bandwidth compromised? – TheUnexpected Sep 25 '16 at 08:47
  • 1
    The [P] flag tells it to proxy the request, which is bad for your setup. You need to replace it with the [R] flag. See this page for help https://httpd.apache.org/docs/2.4/rewrite/remapping.html – James Swift Sep 25 '16 at 20:17