How to make a multi-regional web application architecture? - ruby-on-rails

My server is in Sweden (DB, ruby on rails web app, nginx). Sometimes people from South Africa and Southeast Asia come to my site.
For these people, the site is very stupid. Ping from Southeast Asia about 200ms. I want to solve this problem. I have no experience with such situations.
CDN will not help because it is only for static information.
I thought I need to make three servers for each region (1 server 1 nginx 1 webapp 1 base 1 region) and configure replication between databases. But I was told it was bad. How then? Maybe Amazon Cloud with RDS?

If you're on AWS could use a Load Balancer with your service running on multiple availability zones.
This is the same on AWS or Google Cloud
There are however a few things to take into consideration, for instance:
where is your db?
is it distributed?
is your service DB hungry?
Every scenario is easy to solve on AWS just by clicking around; meaning adding your service to multiple availability zones is as easy as making your db available across multiple regions as well.

If your server provides a RESTful interface and you want to use AWS for any reason, I would recommend API Gateway, just because it already has an edge-optimization feature: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html
"Edge-optimized API endpoint: The default host name of an API Gateway API that is deployed to the specified region while using a CloudFront distribution to facilitate client access typically from across AWS regions. API requests are routed to the nearest CloudFront Point of Presence (POP) which typically improves connection time for geographically diverse clients. An API is edge-optimized if you do not explicitly specify its endpoint type when creating the API."

Related

Using a private google cloud storage with a custom domain

I have an google cloud storage buckets and one rails app to access this buckets. My app works with files from 1M until 300M in uploads/downloads.
On my rails app I use carriewave gem, so ...all the throughput comes to my app, after to the bucket....until now, everything normal.
Recently I implement GCP direct upload but, the base url is storage.googleapis.com. This is terrible for my customers that have such a high level security in their local networks.
I need that storage.googleapis.com becomes storage.mycustomdomain.com. In this approach my customers will just allow *.mycustomdomain.com in their networks.
Someone could help me?
Tnks
Cloud Storage public objects are served directly from GCP through storage.googleapis.com, as explained in the documentation. From John Hanley’s comment, and according to this guide, Cloud Storage does not directly support custom domains:
Because Cloud Storage doesn't support custom domains with HTTPS on its own, this tutorial uses Cloud Storage with HTTP(S) Load Balancing to serve content from a custom domain over HTTPS.
The guide goes into creating a load balancer service which you can use to serve user content from your own domain, using the buckets as the service backend. Otherwise, it is also possible to create a CDN which is supported by Cloud Storage and uses a custom domain, as mentioned by the blog objectives:
I want to serve images on my website (comparison for contact lenses) from a cloud bucket.
I want to serve it from my domain, cdn.kontaktlinsen-preisvergleich.de
I need HTTPS for that domain, because my website uses HTTPS everywhere and I don’t want to mix that.
This related thread also mentions implementation of a CDN to use a custom domain to serve Cloud Storage objects.

API gateway to my elastic beanstalk docker deployed app

My backend is a simple dockerized Node.js express app deployed onto elastic beanstalk. It is exposed on port 80. It would be located somewhere like
mybackend.eba-p4e52d.us-east-1.elasticbeanstalk.com
I can call my APIs on the backend
mybackend.eba-p4e52d.us-east-1.elasticbeanstalk.com/hello
mybackend.eba-p4e52d.us-east-1.elasticbeanstalk.com/postSomeDataToMe
and they work! Yay.
The URL is not very user friendly so I was hoping to set up API gateway to allow to me simply forward API requests from
api.myapp.com/apiFamily/ to mybackend.eba-p4e52d.us-east-1.elasticbeanstalk.com
so I can call api.myapp.com/apiFamily/hello or api.myapp.com/apiFamily/postMeSomeData
Unfortunately, I can't figure out (i) if I can do this (ii) how to actually do it.
Can anybody point me to a resource that explains clearly how to do this?
Thanks
Yes, you can do this. For this to happen you need two things:
a custom domain that you own and control, e.g. myapp.com.
a valid, public SSL certificate issued for that domain.
If you don't have them, and want to stay within AWS ecosystem, you can use Route53 to buy and manage your custom domain. For SSL you can use AWS ACM which will provide you with free SSL certificate for the domain.
AWS instructions on how to set it up all is:
Setting up custom domain names for REST APIs

Hosting non-profit application using Docker container

I've been developing a web application for a very amazing charity for the past two months. I have a Docker image, container, repository etc. and want to publish my web app for the public to see and interact with. It is a UK/Ireland based charity.
The problem is that hosting seems to be quite expensive. Is there any discounted/free hosting services available for non-profits to host their applications? I've seen some for US Charities. Are there any services providing a discount which would be able to host my Docker container? Right now it is sitting on the free version of Heroku, which is definitely not suitable for a lot of traffic.
(Also, I'm new to hosting/Docker so any tips/first steps would be well appreciated!)
Azure has an excellent grant plan for verified NPOs you can use for anything (we are using it).
Azure isn't the most user-friendly, but it's probably worth the effort to get to know it.
Amazon Web Services provides a grant of $1000 per year, but you have to pay a $95 admin fee.
AWS, through TechSoup, will make one grant of $1,000 in credits per fiscal year (July 1 to June 30) to eligible 501(c)(3) organizations. Organizations can apply these service credits toward usage fees for all AWS on-demand cloud services, as available by region. AWS credits are not valid for Amazon EC2 Reserved Instances, Amazon Mechanical Turk, AWS Marketplace, Amazon Route53 domain name registration or transfer, or any upfront fee for any service. They are available for monthly support fees.

Failover IP when server on DNS supplied IP fails iOS

My iOS app uses a single hard-code URL api.xyz.com to find our REST service. At the moment there are just two servers running this service, and we use Amazon Route 53 DNS. But I've found that the timeout of an hour (or more) is too long incase one of our servers fails; don't want to leave users in the dark that long.
The alternative would be to implement a failover mechanism in the app. To be honest, I don't like the idea of pulling this low level DNS-related logic in the app, but I don't see another solution at the moment.
So my question is: How do I implement such a failover mechanism on iOS? I'm using AFNetworking for my REST API.
Or, are there better alternatives on server side? At the moment the servers are individually rented ones, so no Amazon, Google, ... cloud service.

my domain name to cloudfoundry instance

I have just deployed my Grails app on public cloudfoundry(myApp.cloudfoundry.me) and i need my domain to point to it. How is this accomplished? or what are the alternatives?
Problem: deploy Grails app via cloudfoundry on cloud with my own domain name instead something.cloudfoundry.me
Resources: i have a virtual server Ubuntu with static public IP available.
Goal: have a way to deploy many of my apps each with their own domain names
If you don't mind sharing how you do it today and, perhaps, if you can reference tutorial that would be very helpful
Thank You,
Cloud Foundry does not currently support custom domain mapping. However, this feature is high on the priority list and development is currently under way. If you do a search at Cloud Foundry Support
you will find a series of posting regarding this issue and some short term workarounds that could be helpful for you and your particular situation.
Thank you eightyoctan! I accepted your replay as answer, however. i wanted share what i end up doing to have my domain point to cloud foundry hosted app
Option 1. i used GoDaddies Forward+Masking to push app on myapp.cloudfoundry.com and then forward+masking on godaddy to have mydomain.com point my app on cloudfoundry....i am sure i am penalized from SEO aspect to some extent but it works so far
Option 2. I also believe the same goal - have my custom domain point to cloud foundry app via Elastic Ip of EC2 as described in the following blog:
http://www.cloudsoftcorp.com/blog/first-steps-with-cloud-foundry-on-amazon-ec2/
Or use Stakato with EC2 that runs on top of cloud foundry from what i can tell. For more:
http://docs.stackato.com/server/ec2.html#vm-ec2
Either way, I hope cloud foundry does get this feature soon so we don't have to make extra steps to accomplish this

Resources