Build Resilient Backend to Your Applications Using IBM Cloud Mobile Foundation

6 min read

Set up a highly available and disaster recovery (HA-DR) topology for your mobile backend using IBM Mobile Foundation

IBM Mobile Foundation from IBM Cloud provides an open, comprehensive, and advanced mobile application backend for mobile devices. It helps enterprises of all sizes to efficiently develop, test, connect, run, and manage mobile applications (apps).  You can read more about the service and get started with developing your mobile backend from the official service documentation available here.

As enterprises move their mission-critical workloads to the cloud, the need for availability increases. Enterprises only trust a reliable and highly available cloud infrastructure to offer an uninterrupted service to their end users. The architecture of IBM Mobile Foundation is built following the design principles of cloud-native applications, which makes building such a resilient architecture quite simple. In this guide, we will walk you through the series of steps involved in setting up a highly available and disaster recovery (HA-DR) topology for your mobile backend using IBM Mobile Foundation.


The following diagram exhibits the topology:

Build Resilient Backend to Your Applications Using IBM Cloud Mobile Foundation


At a high level, the solution involves the following:

  1. Obtain a highly available database service instance to be used by IBM Mobile Foundation service.

  2. Create IBM Mobile Foundation service instances in two or more IBM Cloud regions. Currently, Mobile Foundation is available in the Dallas, Washington DC, London, Frankfurt, and Sydney regions.

  3. Configure a Global Load Balancer (GLB) for failover routing.

The following sections discuss how to achieve the above solution in detailed steps.


  • Use an IBM Cloud account. If you don’t have it already, sign up for an account.

  • Install the IBM Cloud CLI from here.

  • Install the IBM Mobile Foundation CLI from here.

  • Obtain a custom domain for your mobile backend. If you don’t already have one, you can obtain a custom domain from an Internet Domain Registrar like GoDaddy.

Step 1: Obtain a highly available database

IBM Mobile Foundation service uses a database for persistence. We need to obtain a DB2 service instance from here that offers high availability. Information on how to enable a DB2 service instance for high availability is available here.

To be able to configure the database service with IBM Mobile Foundation service, we will create a user-provided service with the credentials of the database service obtained. The credentials can be obtained from the Service Credentials tab of the database service instance from the IBM Cloud console. Copy the credentials to a file (db-credentials.json) on your file system.

Now, create an user-defined service using the following commands in all the regions where IBM Mobile Foundation service instance will be provisioned:

ibmcloud login -a <API_ENDPOINT>
ibmcloud target —cf
ibmcloud cf cups MFPdashDBUserDefined -p /path/to/db-credentials.json


  • API_ENDPOINT in the above refers to the endpoint to access a particular region. For US-SOUTH, the value will be, and for US-EAST, the value will be

  • Ensure that the name used for the user-provided service is MFPdashDBUserDefined.

Step 2: Create IBM Mobile Foundation service instances

Create IBM Mobile Foundation service instances in all the regions you choose to host your mobile backend. The service instance can be created from the IBM Cloud catalog here.

Make sure that you do the following:

  • Choose a plan supported for production. Developer plans do not support HA/DR.

  • Specify the same password to log into the Operations console (under Settings) for both the service instances.

  • For High Availability within a region, it is recommended that we have at least three instances running. Set the number of instances from the Advanced tab.

After the servers are created and are running, we need to ensure that the database schemas for all the servers are same:

  • Obtain the database schema from the primary (or any) service instance using:

    ibmcloud cf ssh -c "cat /home/vcap/app/wlp/usr/servers/mfp/server.env | grep MFPF_DB2_SCHEMA" | cut -d "=" -f2
  • Obtain the service instance GUID using the following command:

    ibmcloud cf service <mobile-foundation-service-instance-guid> --guid

    Use the script to set the database schema for the IBM Mobile Foundation service instances in the remaining regions. The database schema name is obtained from the above command:

    ./dbconfig <mobile-foundation-service-instance-guid> <db-schema-name>

For Single Sign-On to log into the Operation Console between Mobile Foundation Service instances across regions, ensure that all the service instances are configured with the same LTPA keys. Perform the steps below for the same (after both the service instances are created):

  • Copy the ltpa.keys file from the primary instance using the following command:

    cf ssh <mobile-foundation-app-name> -c "cat /home/vcap/app/wlp/usr/servers/mfp/resources/security/ltpa.keys" > ltpa.keys(where mobile-foundation-app-name refers to the CF app name provisioned for the Mobile Foundation service instance).
  • Propagate the obtained LTPA keys to the other service instance(s) using the Service Dashboard (from IBM Cloud console) in the Settings section. After the LTPA keys are updated, click on Update Server on the next page.

  • Restart/re-stage the server.

Step 2: Create IBM Mobile Foundation service instances
  • Verify that you’re able to access and login into both the service instances.

Step 3: Configure a Global Load Balancer (GLB) for Failover Routing

We’ll now configure a Global Load Balancer (GLB) to route app requests to the secondary region in the event that a primary region is unreachable. We’ll configure the IBM Cloud Internet Service to intercept requests to the application and achieve this Disaster Recovery (DR) failover.

  • Create an instance of the Internet Services from here.

  • After the service is created, click on Let’s get started.

  • Provide the domain name you’ve obtained as specified in the prerequisites section and click Connect and continue.

Step 3: Configure a Global Load Balancer (GLB) for Failover Routing
  • Skip the next step: Set up your DNS records (optional)

  • In the next step of Delegate domain management, we need to delegate the name server records of our domain to Internet Services as explained below. 

Delegate domain management
  • Copy the two new NS records from above and configure these name server records in your domain registrar (GoDaddy, for example) under DNS settings.

DNS settings
  • From the IBM Cloud console, verify that the name servers are working by clicking on Check Name Servers.

Check Name Servers

Now, let’s navigate to Reliability -> Global Load Balancer to configure a GLB.

  • Create a Global Load Balancer and name it.

Create a Global Load Balancer and name it
  • Create two origin pools—one each for the IBM Mobile Foundation Service instances created in Step 2.

Create two origin pools—one each for the IBM Mobile Foundation Service instances created in Step 2.
Create two origin pools—one each for the IBM Mobile Foundation Service instances created in Step 2.
  • Provision the GLB instance by clicking on Provision 1 Resource.

  • After the GLB has been provisioned, click on View details under Default origin pools and ensure that the status of the health check and the endpoints in the pool is “Healthy.”

View details under Default origin pools


We’ll now have to register the domain and the route of the GLB in the Cloud Foundry orgs of both the regions where we’ve created the IBM Mobile Foundation service instances. Use the follow commands:

ibmcloud cf create-domain <CF_ORG> <DOMAIN_NAME>
ibmcloud cf create-route <CF_SPACE> <DOMAIN_NAME> <GLB_HOST_NAME>
ibmcloud cf map-route <MOBILE_FOUNDATION_CF_APP_NAME> <DOMAIN_NAME> --hostname <GLB_HOST_NAME>

For example:

ibmcloud cf create-domain
ibmcloud cf create-route dev live
ibmcloud cf map-route primary-mb-Server --hostname live

That’s it! Let’s test this now by deploying a simple adapter.

Verifying the HA/DR across Mobile Foundation Service instances

  • Create a simple adapter using:

    mfpdev adapter create HATestAdapter -t java -p -g

  • Modify the adapter resource class from (src/main/java/com/ibm/mfp/tests/ with the following:

    • Change the value of Path annotation at class level to “/”

    • Annotate the method ”public String getResourceData()” with @OAuthSecurity(enabled = false)

    • Add the following in the body of the method “public String getResourceData()”:

      InetAddress address;
      String hostName;
      String ip;
      try {
      address = InetAddress.getLocalHost();
      hostName = address.getHostName();
      ip = address.getHostAddress();
      } catch (UnknownHostException e) {
      hostName = "Unidentified";
      ip = "";
      }return "Hello from HATestAdapter : HostName = " + hostName + " , HostAddress = " + ip;
    • Specify the mfpfUrl, mfpfUser, mfpfPassword properties in the pom.xml, where mfpfUrl represents the GLB URL of the Mobile Foundation Service. For example,

    • Build and deploy the adapter using:

      mfpdev adapter build all
      mfpdev adpater deploy -x
    • Test the adapter making multiple calls to

      curl https://<GLB_URL>/mfp/api/adapters/HATestAdapter
      (For example, and notice that the traffic is distributed across all the instances of Mobile Foundation Service

Note: When you are building a mobile application, the mobile application should point to the GLB_URL.


The above steps should help you set up a highly available and resilient mobile backend for your apps. We used US-South (primary) and US-East (secondary) as an example, but you may configure other regions of your choice (uk and fr) or (us and uk) or (uk and syd) to achieve higher availability for your apps. Mobile Foundation Service offers support for a number of frameworks, including Swift, Objective-C, Android, Cordova, Web and ReactNative as documented. The next step is to develop and deploy your mobile apps using the framework of your choice.

If you run into any issues setting up this topology, join the conversation on our dedicated Slack channel here: 


Be the first to hear about news, product updates, and innovation from IBM Cloud