MongoDB 4.4: User-Driven Engineering. Ready for You

Mat Keep

#Releases

I’m excited to announce that MongoDB 4.4 – the next release of the MongoDB database – is now Generally Available (GA), and ready for your production applications.

You can spin it up on our fully-managed MongoDB Atlas cloud service, choosing from over 70 regions around the world on AWS, Azure, and Google Cloud. Alternatively, you can get the 4.4 packages from our download center to run it on your systems.

We think of MongoDB 4.4 as “user-driven engineering” – delivering the features and enhancements most demanded by you. Developing 4.4 has been a significant project involving many groups across MongoDB. Our R&D team has invested close to 270,000 engineering hours and closed over 5,200 tickets to bring MongoDB 4.4 to general availability.

So what’s new in MongoDB 4.4?

So let's take a look at what those investments mean for the database and drivers. In this series of blog posts, I want to give you a tour of what’s new and improved in the MongoDB 4.4 release:

  • Today I’ll be taking you through the MongoDB Query Language and drivers.
  • In Part 2 we’ll cover sharding and performance, including the ability to refine your shard keys as your applications grow; and to hedge reads across multiple replicas to avoid busy nodes and preserve your latency SLAs.
  • Part 3 will see us dig into resilience with mirrored reads and new security controls in the cloud.

If you don’t want to wait on me, you can get a view of what each of those posts will cover by downloading the Guide to What’s New in MongoDB 4.4.

MongoDB Query Language and Drivers: New for 4.4

The MongoDB Query Language (MQL) is designed to be rich and expressive, enabling you to build almost any class of transactional and analytical application using a query language that is idiomatic to modern programming languages.

A key part of MQL is the Aggregation Pipeline. With dozens of stages and over 150 operators and expressions, you can process, transform, and analyze data of any structure at scale, using any programming language. MongoDB 4.4 continues to enhance the power of the Aggregation Pipeline with Union and Custom Aggregation Expressions.

Union

Through the new $unionWith aggregation pipeline stage, you can now blend data from multiple collections and aggregation pipelines into a single result set in the database, enabling deeper exploration and analysis of your data.

To illustrate the power of Union consider a time-series application that stores data in separate collections, with each bucketed by month. Creating a union that blends those monthly collections into a single result set enables you to analyze trends over longer time frames without having to return data to the application and creating the union there, or moving data into a data warehouse. You have less code to write, no data movement incurring infrastructure overhead, no data staleness comprising query results – providing your users with fresher and faster insights.

Union $unionWith aggregation pipeline

$unionWith gives you the same functionality as the SQL UNION ALL operator, but takes advantage of MongoDB’s flexible document data model and distributed systems design. This means your source collections aren’t constrained by needing matching schemas, and Union aggregations can be scaled-out across collections spanning multiple shards.

Custom Aggregation Expressions

You can extend the functionality of MongoDB for your specific use cases by defining your own custom expressions in JavaScript and now have them execute on the database server as part of an aggregation pipeline.

Custom Aggregation Expressions

There are many use-cases for Custom Aggregation Expressions. Some of the most common include filtering and projecting complex computed fields for data analysis, i.e. creating custom arithmetic and accumulator expressions, or for complex ETL pipelines.

By co-locating the execution of your custom expressions with your data server-side, you reduce the amount of data you need to pull back to the application, delivering higher performance to your users. Before 4.4, you could execute custom expressions via MapReduce in MongoDB. By now making those expressions available as part of an aggregation pipeline, you get improved ease-of-use through simplified and more efficient syntax and execution.

Additional MQL and Driver Enhancements in MongoDB 4.4

New Aggregation Operators and Expressions

Simplifying your code, it's now easier to search and manipulate strings and evaluate the first and last elements of an array. To simplify schema analysis and performance optimization, you can use new expressions to return the size of binary or BSON objects in your documents. There are a number of new goodies in 4.4, and you can learn more about them in the release notes.

Connection Monitoring and Pooling

Enhancing developer ease-of-use and the observability of your application under increased load, we have standardized the way MongoDB drivers configure and manage connection pooling behavior.

Each driver exposes an API that allows you to subscribe to events emitted from the connection pool, providing you visibility into when the driver opens and closes connections, and clears the pool. Through the API, you can configure connection pool behavior: defining the minimum and maximum number of connections, the maximum idle time, and how long a thread must wait for a connection to become available before throwing an exception. Review the full connection monitoring and pooling spec to learn more.

Global Read and Write Concerns

You can now configure read isolation and write durability guarantees that are applied cluster-wide. This allows you to set the most appropriate defaults server-side for your application, maintaining consistent behavior across all your clients. But it’s not all or nothing – you still have the flexibility to override the default on a per-client or per-session basis in the driver.

Note that global read and write concerns are currently not available in MongoDB Atlas.

New MongoDB Drivers

  • MongoDB Rust Driver GA: Rust is gaining incredible momentum and we are keeping up the pace. Following the alpha release in December of 2019, the MongoDB Rust Driver is officially GA. The highlight of this new GA release is async support, including asynchronous connections and API as well as non-blocking server selection, enabling developers to write safe and fast code more efficiently than ever before.
  • MongoDB Swift Driver GA: The new driver enables developers to apply their existing front-end skills to back-end code, creating a universal programming experience. The MongoDB Swift Driver supports the async API for fast and safe I/O, an ergonomic BSON API to make working with documents more effortless, including CRUD operations, the full breadth of aggregation pipeline operators and stages, along with serialization and conversion to Swift data types.

Getting Started with MongoDB 4.4

A good place to learn more about all of the features and enhancements in our latest release is to watch the on-demand What’s New in MongoDB 4.4 webinar.

Alternatively, if you want to dive straight in, there are multiple ways you can get going:

  • Spin it up 4.4 in the cloud using the fully-managed and global MongoDB Atlas database service.
  • Alternatively, download 4.4 and run on your own infrastructure (select 4.4.x under Version).
  • Review the documentation in the 4.4 Release Notes.

I’ll hope you’ll stick with me through this tour of the latest MongoDB release. Next up I’ll cover sharding and performance.