Tag: mongodb

  • Camp DevOps @ GlueCon 2014

    Camp DevOps @ GlueCon 2014

    campdetailsdevopsy.kinsta.cloud is very pleased to announce that in conjunction with Eric Norlin and Glue Conference 2014,  we will be presenting our inaugural Camp DevOps @ Gluecon on May 20th, one day before Gluecon 2014. Camp DevOps will take place from 8:30 am until 4:30 pm. The event will be held at the Atlas Institute Building at the scenic University of Colorado/Boulder campus. Here is a link to a flyer with more information here.  You can go also get more information by going to Campdevopsy.kinsta.cloud (site is still going up, so be patient if there is a problem) or our Eventbrite page.

    Moving devopsy.kinsta.cloud beyond the 4 walls of the website has always been part of our business plan. Camp DevOps is our own conference brand. Martin Logan, devopsy.kinsta.cloud co-founder has held Camp DevOps before, but this will be the first event since our commercial launch.  Over time what Camp DevOps is and what to expect we hope will be better understood. But since this is the first, let me quickly give some background.

    We recognize there are no shortages of conferences around DevOps. Camp DevOps is not meant to compete with DevOps Days and similar conferences. We think DevOps Days are great events and we will be working with local Meetup groups to help them with DevOps Days in the future.  Camp DevOps are also not meant to compete with Velocity or other enterprise events.  Instead Camp DevOps like devopsy.kinsta.cloud itself is meant to pitch a big tent. We will have content and activities for the different constituents of the growing DevOps community.

    CampDevOps @ Gluecon 2014 will feature keynote presentations (Sanjeev Sharma of IBM and author of “DevOps for Dummies”, Rajat Bhargava, CEO JumpCloud and Howard Diamond, CEO of MobileDay already confirmed), multi-track presentations with one geared for technical audiences and another aimed at business and cultural topics, panel discussions and what we are calling “Hello World”. Hello World will feature hands on learning with DevOps tools. Attendees will need their own computing device to follow along.

    There will also be table top displays, Continental breakfast and lunch served. We are hoping to have a sponsor for dinner as well. The cost to attend Camp DevOps is just $49.99. If you are already registered for Gluecon, you can attend for free. If you are not registered for Gluecon and register for Camp DevOps you will receive a $100 dollar credit towards Gluecon registration. There will also be complimentary shuttle service from the Gluecon hotel, The Omni to the Atlas building at CU/Boulder.

    Attendance is limited so please don’t wait to register!

    Besides the keynote speakers, we also will have presentations from AppDynamics, MongoDB, VictorOps and others. We will be updating the agenda and presenters daily.  We still have room for more track speakers, keynotes, panel and Hello World presenters. If you are interested contact us at CampDevOps@DevOps.com.

    Sponsorship packages are also still available. There are sponsorship opportunities in conjunction with Gluecon and CampDevOps or just Camp DevOps. Contact us at CampDevOps@DevOps.com for details.

  • MongoDB 2.6: Most Significant Release of Mongo Yet?

    MongoDB announced the latest version of the popular NoSQL database yesterday, version 2.6.  I had a chance to speak with Kelly Stirman, Director of Product at Mongo about the release.  The release is chocked full of goodies for Mongo users.  For me chief among them was the new security features highlighted in the press release below. Also the MMS features make it much easier to run Mongo at scale.  One of the things Kelly spoke to me about was to make it easier for first time users to get MongoDB up and running. This is another thing addressed in 2.6.  You can see the full details below.

    Announcing MongoDB 2.6: A Quantum Leap for the World’s Fastest Growing Database

    MongoDB’s Most Significant Release to Date Brings Simplicity and Reliability to Operations, Complete Re-Architecting of Major Server Components and Enterprise-Grade Security

    NEW YORK and PALO ALTO, Calif.—April 8, 2014 – MongoDB today announced the general availability of MongoDB 2.6, the newest release of the database that defines the standard in modern application development. The release builds on five years of innovation and hundreds of thousands of deployments to simplify provisioning and operating MongoDB deployments, making the database developers love for building apps, the database organizations love to run.

    MongoDB makes building applications natural and intuitive – and this release makes it just as natural to run these apps, freeing up the most valuable assets of any organization to innovate and move the world forward, one app at a time.

    “The core of MongoDB has served the community well for the past five years,” said Eliot Horowitz, co-founder and CTO of MongoDB. “In 2007, we set out to prove that a new data model could fundamentally improve the way developers build and run applications. Now we move the industry forward with a management service that improves the way we run apps, allowing organizations to focus on what they do best. We have the opportunity to engineer the primary data management system used for decades. This is a massive task, but we have the community, the engineering talent and the funding necessary to deliver on the promise of what is before us.”

    “This release moves the way we build and run apps an enormous step forward. We are introducing automation features to MMS, now in testing with select users. Over the past two years more than 35,000 members of the community have come to rely on MMS. Users can now provision, upgrade and manage their systems through a simple yet sophisticated interface. Operating MongoDB is now more reliable and effortless than ever before. We have improved the scalability of several critical areas of the database, and completed fundamental changes to the core that will allow us to improve concurrency in MongoDB 2.8 and beyond. We reduced the effort to add some classes of new features by 100x, built a sophisticated query planner with immense potential for further innovation, redesigned write operations and dramatically simplified the maintenance of MongoDB. This is our biggest release ever.”

    With text search, enterprise-grade security and best-in-class analytical capabilities, MongoDB 2.6 enables new classes of use cases. Key features of the release include:

    MMS – MongoDB Management Service simplifies how organizations run MongoDB systems at scale. MMS now includes continuous, incremental backup; point-in-time recovery; monitoring, visualization and alerts on 100+ parameters; on-prem deployments for MongoDB subscribers and a fully-managed solution in the cloud. Alpha features include simple, single-click provisioning and hot upgrades.

    Index Intersection – Index intersection provides more flexible, adaptive analytical capabilities, making it easier to run ad-hoc analyses to answer evolving business questions. Developers no longer need to predict all data access patterns in advance as more than one index can be used to optimize a query.

    Improved Scalability & Performance – Organizations can scale more easily and at lower cost. MongoDB 2.6 provides more efficient use of network resources; oplog processing is 75% faster; classes of scan, sort, $in and $all performance are significantly improved; and bulk operators for writes improve updates by as much as 5x.

    Text Search – Users have come to expect search as a primary means of accessing data in apps. Developers can now deliver search as a feature without the added complexity of a separate, dedicated search engine. MongoDB 2.6 integrates text search into the MongoDB Query Language and the Aggregation Framework, and provides powerful search for 15 languages.

    Enterprise Security – Securing data is a top priority for many organizations, and MongoDB 2.6 provides best-in-class security functionality. Building on the support in MongoDB Enterprise 2.4 for roles, Kerberos authentication and SSL encryption, MongoDB Enterprise 2.6 adds field-level redaction, customizable auditing, LDAP and x509 authentication, collection-level authorization and user-defined roles.

    Bulk Update Operators – Organizations can now manipulate large data volumes more efficiently than ever before. New bulk operations make it simple and efficient to load, update and delete large volumes of data in MongoDB. Bulk operations automatically parallelize updates across the system, and return a report of failed operations that can be retried by the application.

    Pipelined Data Transformations – Data can be summarized, enhanced, aggregated and refined to better serve users from within the database. MongoDB 2.6 provides multi-step data enrichment and transformations natively in the database using a simple declarative interface. With the new $out stage, results sets from the aggregation pipeline can be written to a named collection with no limit to the output size.

    Simplified Operations – MongoDB 2.6 simplifies and lowers the cost of operating MongoDB at scale. Indexing can beperformed in the background, yielding to foreground operations and auto-resumes after restart; with MaxTimeMS operators and developers can specify auto-cancellation of queries, providing better control of resource utilization; mixed SSLconnections; expanded SNMP support; more efficient repair operations; and a new default space allocation configuration provides more predictable performance.

    “In five short years, the MongoDB community has transformed the data management landscape, creating the first compelling alternative to 40 years of relational databases,” said Max Schireson, CEO of MongoDB. “We have created a new and liberating data model, demonstrated mass appeal, significantly improved how engineers build and run modern applications, and secured funding to ensure MongoDB continues for decades to come. With this release we have made massive investments in the database to ensure a strong foundation for continued innovation.”

    MongoDB has a thriving global community with more than 7 million downloads of its open-source database, 1,000 customers, 150,000 online education registrations, 30,000 user group members and 20,000 MongoDB Days attendees.

    Register today for MongoDB World and join developers, ops professionals and executives from all over the world at the largest MongoDB event ever, June 23-25 in New York City.

    Supporting Quotes
    “Release 2.6 is an important milestone. It is packed with many new features and incremental improvements across the board. It removes the 16MB output limit in the Aggregation Framework for querying Big Data. We can now build efficient, complex data processing workflows as 2.6 allows the result of an aggregation pipeline to be stored in another collection directly, without sending it all the way to the client. Additionally, the new wire format and batch APIs enable more efficient client driver implementations, including a more streamlined async API that improves client-side throughput. We are looking forward to continuing innovation and steady execution at MongoDB.” – Yuri Finkelstein, Enterprise Architect, eBay

    “MMS is like a heartbeat, you simply can’t live without it. It is easy to get started with – the installation is really logical and the overall learning curve is quite minimal. If you are playing with sharded clusters in production, you really need MMS.” – Janne Keskitalo, Senior System Manager at Polar

    “MMS is an essential component in our MongoDB tool chain. Monitoring gives us all the insights into MongoDB that we need to make sure all our customers’ systems are healthy. It also helps us to see upcoming issues so that we then can proactively reach out to our users. The backup features integrate seamlessly with the monitoring. We love the great flexibility it gives us with custom snapshots, point-in-time recoveries and most of all, consistent backups across sharded systems.” – Johannes Brandstetter, Chef de Cuisine, MongoSoup

    Resources
    – Register today for MongoDB CTO Eliot Horowitz’s ‘What’s New in MongoDB’ webinar
    – Run MongoDB with confidence, set up your free MMS account today
    – View a demo of MMS’ automation features
    – Download the ‘What’s New in MongoDB 2.6’ whitepaper
    – Release Notes for MongoDB 2.6
    – Sign up for MongoDB University’s free online courses

    About MongoDB, Inc.
    MongoDB makes development simple and beautiful. For tens of thousands of organizations, MongoDB provides agility and the freedom to scale. Fortune 500 enterprises, startups, hospitals, governments and organizations of all kinds use MongoDB because it is the best database for modern applications. Through simplicity, MongoDB changes what it means to build. Through openness, MongoDB elevates what it means to work with a software company.

  • Mobile Apps and Big Data Megatrends Drive Application Performance Management

    Mobile Apps and Big Data Megatrends Drive Application Performance Management

    As the megatrends of Big Data, mobility and cloud continue to reshape the IT landscape many companies are responding by refocusing their solutions to provide better visibility and support for these technologies.  Case in point is AppDynamics new Spring 2014 release announced yesterday (full disclosure, AppDynamics is a sponsor on devopsy.kinsta.cloud but that sponsorship has nothing to do with editorial content, just banners).

    Jyoti Final_1I had a chance to catch up with Jyoti Bansal, founder and CEO of AppDynamics yesterday. Jyoti made it very plain that mobile applications are quickly tipping the bar in terms of what types of applications his customers are asking for support on. That along with enhanced NoSQL support and support of some for some of the hottest languages being used in development today (Node.js and Scala) lead the way in his company’s latest release.

    Gartner has weighed in on the increasing importance of monitoring mobile app performance.  Jonah Kowall, research vice president at Gartner, in a recent report states, “driven by the increasing significance of mobile application endpoints and increasingly dynamic Web technologies, end-user-experience monitoring will become even more important to enterprises. In fact, it is likely to shift its center of gravity from monitoring the end-user experience of individual applications to monitoring and analyzing end-user behaviors across the entire portfolio of applications available to an end-user at any given endpoint.”

    Personally I don’t think any of us need Gartner to tell us that there is an app for just about anything and many of them are mobile. Mobility is changing the way so many of us work. Mobile apps are poised to overtake web browsing sometime this year says Jyoti.

    If anything is bigger than mobile though it may be Big Data. It seems that Big Data is everywhere. I saw an interesting stat the other day, something along the lines of 90% of all the data stored in the world is less than two years old. I guess that explains why we didn’t hear as much about Big Data before that.  In any event there is big money being poured into Big Data solutions. Evidence of this is Intel’s Cloudera investment, $740m for 18% of the company. Cloudera is a Hadoop distributor of course and part of the AppDynamics new Big Data support is for enhanced Hadoop features.

    NoSQL companies have also been a big beneficiary of the Big Data megatrend  and VC investment of course. One of the biggest beneficiaries is MongoDB (again in full disclosure, devopsy.kinsta.cloud is a media sponsor of MongoDB World).  Matt Asay who has written here on devopsy.kinsta.cloud and is also the VP of Marketing and Business Development had this to say about AppDynamics new NoSQL support. “Together with AppDynamics and MongoDB, organizations can now leverage application performance management solutions to gain further insight into their MongoDB-based applications. This partnership allows users end-to-end visibility for optimal performance in production, an important feature for companies as they scale their MongoDB deployments.”

    To be accurate all of these new features in the Spring 2014 release of AppDynamics have actually been available already for at least a few weeks or months. In my conversation with Bansal I asked him that if he didn’t see a little irony in the fact that a DevOps enabler like AppDynamics still did somewhat traditional software releases instead of some sort of continuous delivery.  Bansal said that these once a quarter releases are really just packaging up features that are released in a continuous fashion over the preceding quarter.  These quarterly releases serve as a checkpoint, version control if you will.  In actuality though AppDynamic customers have been getting this functionality as it comes out.

    Application Performance Management seems to be a very hot area. In large part because of the mega trends of Big Data, mobility and cloud. It remains to be seen if these solutions will become part of (by acquisition or partnership) the bigger Application Development Lifecycle Management (ALM) market.

  • MongoDB Replication Pro-tips: Reporting Instances

    MongoDB Replication Pro-tips: Reporting Instances

    Any shop that has a DevOps culture, and that has MongoDB backed applications, uses replica sets… not just for production applications, but for those still in the prototyping phase. Replication is critical for uptime, so your Ops team has been working with your Devs all through the development of your project, and you didn’t defer a replication strategy until after you had a working app.

    Nor did you neglect to plan for your reporting needs. It is a given that beyond running your app, you need to get analytics on user behavior, general use, and other business-specific metrics. You can’t just run reports against your live database, (for reasons I detail below, in case they are not yet obvious to you). In your DevOps shop, developers and admins discussed, at the inception of the project, the plan for sequestering reporting tasks so that they do not interfere with production tasks.

    Keeping Reporting Reads Away From Production

    Limiting reporting queries to dedicated nodes is a canonical example, used all over the MongoDB replication documentation. Reporting does not require writes, and permits eventually consistent data. Daily summaries do not suffer if they are derived from data which is seconds or minutes stale. It does not change the fundamental meaning of user behavior reports if your counts are missing a few actions, and some tallies are slightly misaligned.

    But why is it so important to take advantage of this?

    Aside: The Problem With Mingling Production and Analytics

    Skip this section if this is already a no-brainer for you. If you want some background, read on.

    Consider the working set, the subset of your entire database that MongoDB reads from and writes to over any given time span. Your production environment will have a set of active users, and the documents pertaining to their data will be what the OS attempts to keep in physical memory.

    (Do not let your working set grow larger than RAM! If it’s heading there, you need to shard, so capacity planning is critical. But that’s a separate lesson. Monitor your instances with MongoDB’s free monitoring servicee, and maybe take an upcoming webinar in capacity planning.)

    Even if your database is hundreds or thousands of times the size of your available memory, if you have planned your schema and indices well, MongoDB will run efficiently because the data outside the working set can remain untouched on disk. As users become idle, their documents will fall out of use, and the RAM they occupy will become available to contain documents for new active users.

    Reporting jobs, though, read a wide range of data, do not visit the same data repeatedly, and each reporting task may address completely different data sets. On any database of decent size, this means these jobs require constant ejection of recently used documents from RAM to make room for new documents to be read. If you run these jobs on the same instance that is backing your production work load, your reporting jobs will fight with your production apps for RAM footprint, continuously ejecting your live users’ data, while your app continuously reloads it. Congratulations, you have built a thrashing machine.

    Replica Sets With Dedicated Reporting Instances

    You can build dedicated reporting nodes atop MongoDB replication by taking advantage of hidden replica set members, or tag sets in concert with read preferences. The first method is simpler, the second is more flexible.

    Reviewing MongoDB Replica Sets

    MongoDB Replica Sets create uptime durability by replicating data to all the nodes in a set, and providing seamless fail-over to clients. They contain one primary node that allows writes, while the rest are read-only secondaries. They manage among themselves which is primary, holding elections to determine which node should be primary when conditions require. Replica sets should contain an odd number of members to facilitate rapid elections without ties.

    It is fundamentally not knowable whether unreachable machines are down or if the network has been partitioned, so if a majority of the nodes in a replica set go offline (say, 2 out of a 3-member set), even if a healthy primary remains, it will step down to a read-only secondary. Not doing so could lead to multiple machines declaring themselves primary in the case of a network partition, and horrific data inconsistencies.

    Thus a replica set contains a minimum of 3 members, providing a fault tolerance of one machine failure.

    Reporting Instance, Hidden Member

    Hidden members of a replica set are configured to be priority: 0, to prevent them from ever being elected primary, and to be hidden: true, which prevents clients connected to the replica set from routing reads to it, even if they specify a read preference of secondary.

    To read from this hidden member, you will use a standalone connection, rather than the MongoReplicaSetClient type, and specify slave_ok.

    Hidden Member Setup

    We can use the mongo shell to hide a member of an existing replica set:

    # connect to primary directly
    Kusanagi:~ avery$ mongo --port 29019
    MongoDB shell version: 2.4.3
    connecting to: 127.0.0.1:29019/test
    
    // using my local replica set playground
    PRIMARY> conf = rs.config()
    {
        "_id" : "test",
        "version" : 21,
        "members" : [
            {
                "_id" : 0,
                "host" : "Kusanagi.local:29017",
            },
            {
                "_id" : 1,
                "host" : "Kusanagi.local:29018",
            },
            {
                "_id" : 2,
                "host" : "Kusanagi.local:29019",
            }
        ]
    }
    
    // we'll use members[1], the instance on port 29018
    PRIMARY> conf.members[1].priority = 0
    PRIMARY> conf.members[1].hidden = true
    PRIMARY> conf.version += 1
    PRIMARY> rs.reconfig(conf)
    Tue Apr  1 12:24:34.045 DBClientCursor::init call() failed
    Tue Apr  1 12:24:34.046 trying reconnect to 127.0.0.1:29019
    Tue Apr  1 12:24:34.047 reconnect 127.0.0.1:29019 ok
    reconnected to server after rs command (which is normal)

    Kusanagi.local:29018 is now hidden. It will continue to replicate and vote in elections as usual, but clients connecting to the replica set will never read from it, even if Kusanagi.local:29019 is taken down:

    irb(main):012:0> rs = Mongo::MongoReplicaSetClient.new(["Kusanagi.local:29017", "Kusanagi.local:29018", "Kusanagi.local:29019"])
    => <Mongo::MongoReplicaSetClient:0x3fe06e4fe564 @seeds=[["Kusanagi.local", 29017], ["Kusanagi.local", 29018], ["Kusanagi.local", 29019]] @connected=true>
    irb(main):013:0> rs.primary
    => ["Kusanagi.local", 29017]
    irb(main):014:0> rs.secondaries
    => #<Set: {}>
    # an empty set -- as far as this connection is concerned, there are no secondaries.

    Reporting code would look like this (in Ruby):

    require 'mongo'
    reporting = Mongo::MongoClient.new("Kusanagi.local", "29018", slave_ok: true)
    
    # error checking goes here
    
    reporting['my_application']['users'].aggregate(...)

    Considerations

    Using a hidden member is the simplest way to set up an instance for a dedicated workload such as reporting, however:

    Hidden Members Cannot Be Read From In Case of Emergency

    With 2 ordinary and one hidden member in a replica set, fault tolerance for writing is identical to a regular 3-member set. However, should you lose two nodes, your production application will not be able to gracefully degrade to read-only mode, because your hidden member will not allow replica set client reads. If you just like the simplicity of a hidden member, and cost is not an issue, use a 5-member set (with one member hidden) instead.

    Wrapper Code for Replica Sets Cannot Be Used

    Many teams create application-specific wrappers to add infrastructure knowledge to the clients provided by MongoDB drivers. Since you need to address your reporting instance with a stand-alone connection, you will not be able to reuse this investment, which will make you sad.

    Reporting Instance, Tagged Member

    The more complex, but flexible, method for routing reporting queries to a dedicated node is to use tagging and read preferences.

    As with the hidden member, set one member to priority: 0, but do not set it to be hidden. Instead, assign a tag of use: reporting:

    PRIMARY> conf = rs.config()
    {
        "_id" : "test",
        "version" : 21,
        "members" : [
            {
                "_id" : 0,
                "host" : "Kusanagi.local:29017",
            },
            {
                "_id" : 1,
                "host" : "Kusanagi.local:29018",
            },
            {
                "_id" : 2,
                "host" : "Kusanagi.local:29019",
            }
        ]
    }
    
    // we'll use members[1], the instance on port 29018
    PRIMARY> conf.members[1].priority = 0
    PRIMARY> conf.members[1].tags = { "use": "reporting" }
    PRIMARY> conf.version += 1
    PRIMARY> rs.reconfig(conf)
    [...]

    As before, Kusanagi.local:29018 will never become primary; however, in the case that the other two machines become unreachable, your application will be able to issue reads to the reporting server. It should go without saying that your reporting should be suspended during such an event.

    Your reporting code will look something like this (in Python, this time):

    from pymongo import MongoReplicaSetClient
    from pymongo.read_preferences import ReadPreference
    
    rep_set = MongoReplicaSetClient(
        'Kusanagi.local:29017,Kusanagi.local:29018,Kusanagi.local:29019',
        replicaSet = 'test',
        read_preference = ReadPreference.SECONDARY,
        tag_sets = [{'use':'reporting'}]
    )
    # check to ensure we're not running reporting against the sole remaining secondary
    if rep_set.primary is not None:
        rep_set.my_application.users.aggregate(...)

    The above will only send reporting queries to secondaries tagged use: reporting, and it guards against running at all if there is no available primary. In practice, you should throw exceptions and handle them in your escalation code if you find no primaries! Better still, your monitoring could set runtime-available values so you can branch on, for example, reporting_system.ok().

    Benefits and Considerations

    Using tags and read preferences allows a few degrees of flexibility that are not possible with hidden members.

    Reporting Instances Can Be Easily Added

    Because your connection code is declarative, rather than specific to a particular host, to add more nodes for reporting jobs, just add them and tag them, like so:

    PRIMARY> rs.add({_id:3, host:"Kusanagi.local:29020", priority:0, tags:{'use':'reporting'}})

    Your existing code will make use of the new capacity, and the replica set will continue operating without triggering an election and disconnecting your clients.

    Reporting Instances Can Be Shifted or Dropped

    The reporting tag can be moved, or even removed if you need to offer read bandwidth to other jobs in a pinch. A reconfiguration like this will trigger an election and disconnect all your clients, but this is no worse than any other option. Note: It is an anti-pattern to increase your general capacity by distributing production reads to secondaries. This is only an emergency measure.

    Some Drivers Require Manual Sync

    The Ruby driver (as of 1.9.2), for example, does not refresh its view of the replica set unless the client is initialized explicitly to do so with refresh_mode: :sync. Check your driver documentation.

    Conclusion

    Simple replication setup has been one of my favorite operational aspects of MongoDB since its introduction pre–1.0, when it made MySQL replication look like something out of the stone age. It was a little rough around the edges back then, but has truly come into its own. Whether you use tag sets or hidden members, building a reporting infrastructure atop MongoDB’s replication features simplifies operations, letting you focus on building a great application.

  • devopsy.kinsta.cloud is Now an Official Media Sponsor of MongoDB World

    mongodbworlddevopsy.kinsta.cloud, the place where the world meets DevOps is happy to report that we will be an official media sponsor of the upcoming MongoDB World conference. The event is in NYC at the Sheraton New York Times Square, 811 7th Ave, New York, NY 10019 on June 23-25, 2014.

    devopsy.kinsta.cloud will be providing live coverage of the event throughout the conference. We will also have some interviews with speakers leading up to the event. Some of the headliners for MongoDB World are:

    mongoworldspeakers

     

    MongoDB World promises to be the best and biggest MongoDB event yet. devopsy.kinsta.cloud will be there to give you a bird’s eye view.

  • MongoDB Needs and Loves DevOps

    MongoDB Needs and Loves DevOps

    DevOps is about more than just running infrastructure smarter, with more automation. It’s a means to engineering agile, robust, and modern software by blending the traditionally siloed areas of administration and development. This means infrastructure as code, and developer concern for operations. It means more than calling sysadmins “DevOps Engineers”; it means operators and developers working together seamlessly. NoSQL in general is a solution that by it’s nature loves DevOps, and it thrives under teams that take a DevOps approach, but it can really hurt you if you do not. MongoDB is no exception to this rule. It has gained enormous traction in the developer community by blending flexibility, features, and performance. Some teams have been seduced by the ease with which they set up MongoDB for development, and neglect to think about capacity planning, tuning, monitoring, and maintenance. Do not let this happen to you! Or you will pay the price at 3am when you are scrambling to figure out why your swell app has ground to a halt. Instead, take the time to learn MongoDB’s needs and capabilities, because it doesn’t just make development easy, it can truly sweeten operations with things like hassle-free replication and full access to administrative tasks via the same API used to perform data access. Let’s have a look at MongoDB from a DevOps perspective.

    DevOps Wants:

    Clueful administrators.

    There isn’t much room in the DevOps movement for system administrators who don’t speak at least one high-level language. I personally find Ruby most appealing to to me for systems programming, but Python is also a fine choice. MongoDB admins should be practiced at performing administrative tasks in both the javascript shell and the programming language of their choice, setting the stage for a rich infrastructure monitoring and automating codebase. Administration best practices are extensively, if not exhaustively, documented in the administration docs, so start there. Pay particular attention to the Operational Strategies section of the manual, which provides a checklist of concerns you should address as you plan your system’s design and deployment.

    Developers who know the ramifications of their infrastructure.

    The age of throwing applications over the wall to operations is mercifully drawing to a close. Developers must understand the nature of their infrastructure, how to best utilize it, and how it handles failures. MongoDB affords developers the ability to code to infrastructure details without coupling to particular instances, or even hostnames. In this, tags, write concerns, and read preferences are your friends. Code that runs reports (which should be kept away from your production instances) can specify that it will read only from instances tagged as “reporting”. Admins can add instances tagged as ‘reporting’, or swap which instances have that tag, with a few lines of code. Refer to the end of this article for example code.

    Infrastructure state to alert cleanly, and for trends to be visualized.

    The MongoDB Monitoring manual section provides an overview of the ways to monitor your instances, including 3rd party solutions, both self-hosted and SaaS. MongoDB Management Service is MongoDB, Inc.’s free monitoring, trending, and alerting service, which you should set up from day one to monitor every single instance you rely on.

    Infrastructure to be programmable.

    Ok, you are monitoring your instances, why not work on automating your infrastructure to respond to faults and load requirements? While MMS is a no-brainer, it’s not going to plug into your infrastructure code. You can roll your own integration using MongoDB’s handy exposure of its internals via database commands, and for replication, the local database. For example, you can check on replica set lag in Python like so:

    import pymongo
    # three mongods running on my laptop
    c = pymongo.MongoReplicaSetClient(
        'Kusanagi.local:29017,Kusanagi.local:29018,Kusanagi.local:29019',
        replicaSet='test'
    )
    
    rs_status = c.admin.command('replSetGetStatus')
    
    lag_threshold = 120 # up to two minutes of replica lag is ok for this example
    primary_optime = [ member['optime'].as_datetime()
        for member in rs_status['members'] if member['state'] == 1 ][0]
    secondary_optimes = [ member['optime'].as_datetime()
        for member in rs_status['members'] if member['state'] == 2 ]
    for secondary_optime in secondary_optimes:
        if ( (primary_optime - secondary_optime).total_seconds > lag_threshold):
            # do stuff

    Provisioning MongoDB instances programmatically on Amazon EC2 is easy with the official AMIs, but automating MongoDB infrastructure goes beyond that. Learn to use the database commands to configure replica sets, because you can script joining new instances to a set. If you use sharding, you can update tag ranges for sharded clusters to migrate chunks to shards specifically provisioned to warehouse data.

    Disaster recovery to be robust and automated.

    There are numerous ways to back up MongoDB, and the one you pick should be appropriate for your deploy. So read through your options in the backups section of the MongoDB Manual. You should probably read that section twice.

    To aid in release management.

    By being schema-free, MongoDB frees enterprises from the hassles of schema alterations and their attendant maintenance windows. Instead of altering a user table to include a new column for “birthplace”, a new release of your application will just begin to write the user document with that attribute included. Naturally, your user profile rendering will not assume this value is set and throw an exception, it will just not display “birthplace”. This does not excuse you from change management! In a DevOps shop, everything about monitoring that applies to production applies to your integration environment, which I sincerely hope is continuous. Configure all the monitors you’d have in production, and alert developers when metrics go out of range.

    Closing Thoughts

    In a DevOps culture, admins read code, developers plan infrastructure, and they both attend the same planning meetings. Engineers who work with MongoDB, both in operations and development, should read the WHOLE manual. If your developers read the development section and your admins read the administration section, you’re really only doing Dev and Ops.

    Example Code – Tags

    Tagging an instance of a replica set looks like this in the MongoDB shell:

    test:PRIMARY> config = rs.config()
    {
        "_id" : "test",
        "version" : 2,
        "members" : [
            {
                "_id" : 0,
                "host" : "Kusanagi.local:29017"
            },
            {
                "_id" : 1,
                "host" : "Kusanagi.local:29018"
            },
            {
                "_id" : 2,
                "host" : "Kusanagi.local:29019"
            }
        ]
    }
    test:PRIMARY> config.members[0].tags = { "use": "production" }
    { "use" : "production" }
    test:PRIMARY> config.members[1].tags = { "use": "reporting" }
    { "use" : "reporting" }
    test:PRIMARY> config.members[2].tags = { "use": "production" }
    { "use" : "production" }
    test:PRIMARY> rs.reconfig(config)
    Fri Mar  7 18:35:25.040 DBClientCursor::init call() failed
    Fri Mar  7 18:35:25.042 trying reconnect to 127.0.0.1:29017
    Fri Mar  7 18:35:25.042 reconnect 127.0.0.1:29017 ok
    reconnected to server after rs command (which is normal)

    Here’s Ruby code, assuming the same config:

    require 'mongo'
    
    # I'm running 3 mongods on my laptop
    rset = Mongo::MongoReplicaSetClient.new(["Kusanagi.local:29017",
                                            "Kusanagi.local:29018",
                                            "Kusanagi.local:29019"])
    
    # using the local db to get current config
    config = rset['local']['system.replset'].find_one() 
    admin_db = rset['admin']
    config['members'][0]['tags'] = { "use" => "production" }
    config['version'] += 1  # mongod avoids reconfig conflicts by insisting on an increasing version value
    verify_version = config['version']
    begin
        admin_db.command({ 'replSetReconfig' => config })
    rescue Mongo::ConnectionFailure # expect your connection to close during this operation
        actual_version = rset['local']['system.replset'].find_one()['version']
        raise unless actual_version == verify_version
    end

    Specifying tag sets only applies to reads from secondaries (since there is only one primary to choose from). In Ruby, it looks like this:

    rset = Mongo::MongoReplicaSetClient.new(["Kusanagi.local:29017",
                    "Kusanagi.local:29018", "Kusanagi.local:29019"])
    analytics = rset['analytics']  # say we have an 'analytics' DB
    cursor = analytics['page_views'].find({'page' => 'home'},
                                            :read => :secondary,
                                            :tag_sets => {:use => 'reporting'})

    This query specifies, with the :read option, that only secondaries should answer, and with the :tag_sets option, that only secondaries tagged with 'use': 'production' can be used. If I were to shut down members[0] (Kusanagi.local:29017) while it was primary, and members[1] (Kusanagi.local:29018) became primary, the above query would fail, because as primary it’s no longer eligible to answer queries directed at secondaries, even though member 1 is tagged as use: 'production'. This is exactly what you want, to keep your reporting queries from hosing your production instance. After taking stock of the situation, you might decide to assign 'use': 'reporting' to member 3, and the above query would then again work. Note that the MongoReplicaSetClients created by the Ruby driver do not by default refresh replica set state (as of v1.9.2), they use the config that was present when the connection was established (this is not the case for all drivers, make sure you determine your driver’s behavior). This means that if you reassign tag values, existing connections will not notice the change. If I were to change the tags for member 1 to 'use': 'not reporting', the above query would not fail, it would route the query right to member 1. So if you are using tagging, and Ruby, instantiate your client with the refresh_mode option:

    rset = Mongo::MongoReplicaSetClient.new(["Kusanagi.local:29017",
                "Kusanagi.local:29018", "Kusanagi.local:29019"],
                :refresh_mode => :sync)

    See the MongoReplicaSetClient documentation for details. The Python driver handles this by launching a background process to monitor Replica Set health and config changes, but the API does not document any means to configure its polling interval.

  • DevOps: It’s All Open Source’s Fault

    DevOps: It’s All Open Source’s Fault

    Blame DevOps on open source. After all, it was the open source movement that gave developers the idea that they were free to code, free to build applications and other software for their companies without needing prior approval. It was open source that crowned developers kingmakers. It was open source that gave developers the freedom to not only write code, but also manage it.

    It was open source that gave us DevOps.

    DevOps: Freedom To Get Stuff Done

    Traditionally, IT operations has been a specialized task, an exclusive one that largely controlled the code allowed to run within the enterprise. Given the fact that all software had to be purchased before it could be run, there was little risk of developers or anyone else introducing rogue software into the hallowed halls of the data center.

    Enterprises were able to enforce policies because all software had to start with Purchasing and end with Operations. There simply was no other viable way to get software into the enterprise.

    That is, until open source.

    Open source ruined the neat and tidy relationship between Purchasing and Operations. Suddenly software didn’t have to be purchased. It could simply be downloaded. As pressures mounted on lines of business to accelerate their pace of innovation, developers stepped up: “I have an open source project for that.”

    Operations fought back, trying to crimp open source adoption. They failed.

    There simply was too much pressure on developers to get stuff done. Once Amazon gave developers a home outside the data center to deploy their code, the battle was over and a new model for building and managing code was born. Dubbed DevOps, the movement gave developers end-to-end control over their creations.

    Since 2011, DevOps adoption has increased 26%, according to a 2013 survey by Puppet Labs, resulting in 50% application failures and the ability to recover up to 12X faster. The rise in DevOps also translates into the ability to ship code 30X faster. All of which is expressed in a separate CA Technologies survey of senior IT decision-makers, which found that improvements to the customer experience is by far the biggest reason enterprises are embracing DevOps. 

    Given these improvements, there’s no way we’re going back to Operations-focused IT.

    Blessing Or Curse?

    All of which is not to suggest that DevOps has been an unalloyed blessing. In my experience, developers are often unprepared or unwilling to take on the burden of managing their applications in production. Trained for years on the idea that they could build an application and dump it on Operations to manage, developers are discovering that the “Ops” in DevOps is real, and sometimes really a pain.

    For example, one big problem is that production environments and dev/test environments are typically very different. An application that works flawlessly in a small-scale test environment may miss a whole class of errors that only occur in the presence of the more complex production environment (e.g. problems that only occur when application changes interact with a complex, zoned network topology).

    The reality is that over-optimizing for Ops (safe, secure and slow) or Development (Fast, opportunistic, iterative) proves sub-optimal. A balance is needed.

    But that balance increasingly skews toward upgrading Ops to meet developer demands. Indeed, developers are writing a host of infrastructure and tools to help other developers better manage their creations. Often such tooling is SaaS-based, and a significant percentage is open source, allowing developers to continue to skirt the controls of Operations while maintaining flexibility. Companies like Boundary, Puppet Labs, SumoLogic and more have arisen to make operations easier for DevOps professionals, among others.

    My own company, MongoDB, develops the most popular database for modern applications. Universally lauded for how easy MongoDB makes development, our tools for facilitating the operation of MongoDB at scale have lagged. Over the past two years we have been building out monitoring, back-up and other management tooling for MongoDB. It’s simply not enough anymore to forget the “Ops” in DevOps.

    No Putting The DevOps Genie Back In The Bottle

    I expect we’ll see this trend continue. The power of developers will increase in large part because the industry will better enable them to manage their applications, or to work more seamlessly with their Ops peers. But the era of Ops dictating to developers is over.

    Blame open source.