June 24, 2022 | Updated: October 25, 2022
We’re proud to announce further expansion in 2023 in the Middle East with the launch of MongoDB Atlas on AWS in the United Arab Emirates (UAE) region. MongoDB Atlas is now available in 22 AWS regions around the world, including eight Asia Pacific regions and three Middle East and Africa regions.
The UAE region is an AWS Recommended Region, meaning it has three Availability Zones (AZ), bringing significant infrastructure to the Middle East. After the expansion in 2023, when you deploy a cluster in the UAE, Atlas automatically distributes replicas to the different AZs for higher availability. If there’s an outage in one zone, the Atlas cluster will automatically fail over to keep running in the other two. And you also will be able to deploy multi-region clusters with the same automatic failover built-in.
We’re delighted that — as with customers in Bahrain, Cape Town, and more — United Arab Emirates organizations will be able to keep data in their own country, delivering low-latency performance and ensuring confidence in data locality. We’re confident our UAE customers in government, financial services, and utilities in particular will appreciate this upcoming capability as they build tools to improve citizens’ lives and better serve their local users.
MACH Aligned for Retail: API-First
Retailers must constantly evolve to meet growing customer expectations and remain competitive. Both their internal- and external-facing applications must be developed using principles that promote agility and innovation, moving away from siloed architectures. As discussed in the first article of this series , the MACH Alliance promotes the development of modern applications through open tech ecosystems. MACH is an acronym that represents Microservices, API-first, Cloud-native SaaS, and Headless. MongoDB is a proud member of the Alliance, providing retailers with the tools to build highly flexible and scalable applications. This is the second in a series of blog posts focused on MACH and how retail organizations can leverage this framework to gain a competitive advantage. In this article, we’ll discuss concepts relating to the second letter of MACH: API-first. Read the first post in this series, "MACH Aligned for Retail: Microservices." What is an API-first approach and why is it important? An application programming interface (API) is a set of routines, protocols, and tools that allow applications, or services within a microservices architecture, to talk to each other. APIs can be seen as messengers that deliver requests and responses. Applications built around APIs are said to be API-first. With this approach, the design and development of APIs come before the software implementation. Typically, an interface is created that is used to host and develop the API. The development team will then leverage the interface to build the rest of the application. This methodology enables developers to have access to specific functionalities of external applications or other microservices within the same application, depending on their needs. It promotes reusability because functionalities are interoperable with mobile and other client applications. In addition, applications developed with an API layer in mind can adapt to new requirements more easily because additional services and automation can be integrated into production when new requirements arise, therefore remaining competitive for longer. An API-first approach to developing applications The role of API-first in retail APIs play a crucial role in deeply interconnected systems that need to interface with other internal applications, third-party partners, and customers — all key areas when it comes to developing powerful retail applications. Think about how an e-commerce platform connects to the different systems making up the purchase process, such as inventory management, checkout, payment processing, shipping, and loyalty programs. The use of APIs is deeply interlinked with the concept of microservices . Software and data need to be decoupled to enable retailers to meet ever-increasing requirements, including omnichannel and cross-platform integration, seamless experiences across physical and online stores, and the ability to leverage real-time capabilities that enable differentiating features, such as live inventory updates and real-time analytics. APIs can be seen as a bridge for loosely coupled microservices to communicate with each other. Besides enabling a microservices architecture, an API-first approach offers the following additional benefits: Avoid duplication of efforts and accelerate time to market . Developers can work on multiple frontends at the same time, being confident that functionalities can be integrated by embedding the same APIs once ready. Think of multiple development teams working on an e-commerce web application, mobile portal, and internal inventory management system all at the same time. An API enabling the placement of a new order can be seamlessly leveraged by the web and mobile application and fed into the inventory management system to aid warehouse workers. Bug-fixing and feature enhancements can happen simultaneously, avoiding duplication of efforts and allowing new capabilities to be released to market more quickly. Reduce risks and operating costs . An API-first approach enables system stability and interoperability from the beginning because API efficiency is placed at the center of the development lifecycle and is no longer an afterthought once the application or functionality has been developed. This approach reduces the risk for retailers and saves money and effort in troubleshooting unstable systems. Enable new opportunities and scale faster . A flexible approach revolving around APIs provides more opportunities when it comes to integrating and refactoring the way different client applications and microservices communicate with each other, allowing retailers to improve and scale their IT offering in a fraction of the time. This approach also changes the way retailers can interact with external partners and do business with them since they can be provided with the tools to easily integrate with the retailer’s offering. Achieve language flexibility . Effective retailers need to have the capability to adapt their digital offering to different regions and languages. The plug-in capabilities of API-first allow developers to offer language-agnostic solutions that different microservices can integrate with, leveraging region-specific frontends. Steps to an API-first application What is the alternative? The four MACH Alliance principles combined (Microservices, API-first, Cloud-native SaaS, Headless) act as a disrupting force compared to the way applications were built until recently. Adapting to a new technology paradigm requires effort and a different developer mindset. But what was there before? From an API-first perspective, it can be said that the opposite is code-first. With this approach, application development starts in the integrated development environment (IDE), in which code is written and the software takes shape. Development teams know that they will need to build an interface to be able to interact with each function of the code, but it is seldom a priority; developing core functionalities takes precedence over the interface where those functionalities will be hosted and accessed. When the time comes for the interface to be developed, the code has already been defined. This means the API is developed around existing code rather than vice versa, which poses limitations. For example, developers might not be able to return data the way they want because of the underlying data schema. The code-first approach Bottlenecks can also occur as other teams requiring the API will need to wait until the code is finalized to be able to embed it in their underlying applications. Any delays in the software development lifecycle will hold them up and delay progress. Although a code-first approach might have worked in the past, it is no longer suitable for dealing with highly interconnected applications. Learn more about how MongoDB and MACH are changing the game for ecommerce. How MongoDB helps achieve an API-first approach Simply lifting and shifting monolithic applications to a microservice and API-first architecture will only provide minimal benefits if they are still supported by a relational data layer. This is where most of the bottlenecks occur. Changes to application functionalities will require constant refactoring of the database schemas, object-relational mapping (ORM), and refining at the microservice level. Moving to a modern MACH architecture requires a modern data platform that removes data silos. The MongoDB developer data platform provides a flexible data model, along with automation and scalability features to adapt to even the most challenging retail use cases and to multiple platforms (e.g., on-premises, cloud, mobile, and web applications). MongoDB Atlas, MongoDB’s fully managed cloud database, also provides capabilities to manage the data layer end to end via APIs, such as the MongoDB Atlas Data API . This is a REST-like, resilient API for accessing all Atlas data that enables CRUD operations and aggregations with instantly generated endpoints. This is a perfect answer to an API-first approach, since developers can access their data using the same principles leveraged to connect to other applications and services. The MongoDB Atlas Data API workflow MongoDB’s Atlas Data API provides several other benefits, allowing developers to: Build faster with developer-friendly data access. Developers work with a familiar, REST-like query and response format, no client-side drivers are necessary. Scale confidently with a resilient, fully managed API that reduces the operational complexity needed to start reading and writing your data. Integrate your MongoDB Atlas data seamlessly into any part of your stack — from microservices to analytics workloads. This article has provided only a sample of what can be leveraged via MongoDB’s APIs. The MongoDB Query API provides a comprehensive set of features to seamlessly work with data in a native, familiar way. It supports multiple index types, geospatial data, materialized views, full-text search, and much more. In the next part in this MongoDB and MACH Alliance series, we will discuss how a cloud-native SaaS architecture can enable full application flexibility and scalability. Read the first post in this series, "MACH Aligned for Retail: Microservices."
Modernize your GraphQL APIs with MongoDB Atlas and AWS AppSync
Modern applications typically need data from a variety of data sources, which are frequently backed by different databases and fronted by a multitude of REST APIs. Consolidating the data into a single coherent API presents a significant challenge for application developers. GraphQL emerged as a leading data query and manipulation language to simplify consolidating various APIs. GraphQL provides a complete and understandable description of the data in your API, giving clients the power to ask for exactly what they need — while making it easier to evolve APIs over time. It complements popular development stacks like MEAN and MERN , aggregating data from multiple origins into a single source that applications can then easily interact with. MongoDB Atlas: A modern developer data platform MongoDB Atlas is a modern developer data platform with a fully managed cloud database at its core. It provides rich features like native time series collections, geospatial data, multi-level indexing, search, isolated workloads, and many more — all built on top of the flexible MongoDB document data model. MongoDB Atlas App Services help developers build apps, integrate services, and connect to their data by reducing operational overhead through features such as hosted Data API and GraphQL API. The Atlas Data API allows developers to easily integrate Atlas data into their cloud apps and services over HTTPS with a flexible, REST-like API layer. The Atlas GraphQL API lets developers access Atlas data from any standard GraphQL client with an API that generates based on your data’s schema. AWS AppSync: Serverless GrapghQL and pub/sub APIs AWS AppSync is an AWS managed service that allows developers to build GraphQL and Pub/Sub APIs. With AWS AppSync, developers can create APIs that access data from one or many sources and enable real-time interactions in their applications. The resulting APIs are serverless, automatically scale to meet the throughput and latency requirements of the most demanding applications, and charge only for requests to the API and by real-time messages delivered. Exposing your MongoDB Data over a scalable GraphQL API with AWS AppSync Together, AWS AppSync and MongoDB Atlas help developers create GraphQL APIs by integrating multiple REST APIs and data sources on AWS. This gives frontend developers a single GraphQL API data source to drive their applications. Compared to REST APIs, developers get flexibility in defining the structure of the data while reducing the payload size by bringing only the attributes that are required. Additionally, developers are able to take advantage of other AWS services such as Amazon Cognito, AWS Amplify, Amazon API Gateway, and AWS Lambda when building modern applications. This allows for a severless end-to-end architecture, which is backed by MongoDB Atlas serverless instances and available in pay-as-you-go mode from the AWS Marketplace . Paths to integration AWS AppSync uses data sources and resolvers to translate GraphQL requests and to retrieve data; for example, users can fetch MongoDB Atlas data using AppSync Direct Lambda Resolvers. Below, we explore two approaches to implementing Lambda Resolvers: using the Atlas Data API or connecting directly via MongoDB drivers . Using the Atlas Data API in a Direct Lambda Resolver With this approach, developers leverage the pre-created Atlas Data API when building a Direct Lambda Resolver. This ready-made API acts as a data source in the resolver, and supports popular authentication mechanisms based on API Keys, JWT, or email-password. This enables seamless integration with Amazon Cognito to manage customer identity and access. The Atlas Data API lets you read and write data in Atlas using standard HTTPS requests and comes with managed networking and connections, replacing your typical app server. Any runtime capable of making HTTPS calls is compatible with the API. Figure 1: Architecture details of Direct Lambda Resolver with Data API Figure 1 shows how AWS AppSync leverages the AWS Lambda Direct Resolver to connect to the MongoDB Atlas Data API. The Atlas Data API then interacts with your Atlas Cluster to retrieve and store the data. MongoDB driver-based Direct Lambda Resolver With this option, the Lambda Resolver connects to MongoDB Atlas directly via drivers , which are available in multiple programming languages and provide idiomatic access to MongoDB. MongoDB drivers support a rich set of functionality and options , including the MongoDB Query Language, write and read concerns, and more. Figure 2: Details the architecture of Direct Lambda Resolvers through native MongoDB drivers Figure 2 shows how the AWS AppSync endpoint leverages Lambda Resolvers to connect to MongoDB Atlas. The Lambda function uses a MongoDB driver to make a direct connection to the Atlas cluster, and to retrieve and store data. The table below summarizes the different resolver implementation approaches. Table 1: Feature comparison of resolver implementations Setup Atlas Cluster Set up a free cluster in MongoDB Atlas. Configure the database for network security and access. Set up the Data API. Secrect Manager Create the AWS Secret Manager to securely store database credentials. Lambda Function Create Lambda functions with the MongoDB Data APIs or MongoDB drivers as shown in this Github tutorial . AWS AppSync setup Set up AWS Appsync to configure the data source and query. Test API Test the AWS AppSync APIs using the AWS Console or Postman . Figure 3: Test results for the AWS AppSync query Conclusion To learn more, refer to the AppSync Atlas Integration GitHub repository for step-by-step instructions and sample code. This solution can be extended to AWS Amplify for building mobile applications. For further information, please contact email@example.com .