Sunday, May 1, 2016

The Curious Case of the WordPress Docker Container | @DevOpsSummit #DevOps

By JP Morgenthal

Article Rating:

May 1, 2016 10:00 AM EDT

Reads:

595

I have an article in the recently released "DZone Guide to Building and Deploying Applications on the Cloud" entitled "Fullstack Engineering in the Age of Hybrid Cloud". In this article I discuss the need and skills of a Fullstack Engineer with relation to troubleshooting and repairing complex, distributed hybrid cloud applications. My recent experiences with troubleshooting issues with my Docker WordPress container only reinforce the details I wrote about in this piece. Without my comprehensive understanding of both the infrastructure and application layer I don't believe I could have achieved resolution (if I have, but more on that later).

1969479-dz-cloud2016cover-lgMy Docker WordPress container has always had issues with the "Error Connecting to Database" issue, but initially it would happen once a month and I would just re-start the container. I had read that the issue was fixed by moving to WordPress 4.5, so I upgraded, which came with its own challenges given these containers are supposed to be immutable.

Unfortunately, I designed my container when Docker architecture was in its infancy and so separating out and linking a MySQL container and the WordPress container as well as storing data on a separate volume are all features which emerged, or became more easily used, in later versions. Eventually, I will need redesign around 1.11 features, but for now, I'm just trying to keep up what I currently have. I did try just moving the database files onto permanent storage mapped in to the container as a volume, but all I did was fight with file permissions for a day and MySQL never ended up starting.

Recently, it became more and more difficult to keep the container up, so I upgraded to the latest Ubuntu 14.04 kernel and when that didn't seem to help the issue I upgraded Docker from 1.4 to 1.11. None of these seemed to correct the issue. However, Docker 1.11 leverages the new architecture and uses cgroups, which resulted in cgroup out of memory thread killer posting messages to my console.

Screen Shot 2016-04-29 at 6.13.20 AM

Now, I could see that mysqld was being terminated at some point due to insufficient memory. To solve the memory issue, I tried optimizing the WordPress LAMP stack for low memory and even migrated from a 1G virtual machine to a 2G instance. It seems no matter how much memory I threw at this problem the longest the WordPress site would be active before the database connection issue appeared was an hour.

Totally baffled at this point, I started chasing down a lead regarding WordPress issues occurring on my cloud service provider. It seemed the issue I was seeing was happening to many others on Digital Ocean, perhaps this was a VPS (DO's Droplet architecture is VPS-based) issue and not a Docker issue. DO responded on its forum to the various postings stating that running out of memory is common result of the known XML-RPC Denial of Service attack.  XML-RPC is the API interface for WordPress.

Wait! What am I doing? No one's going to bother attacking my little old blog, it can't be that. Back to optimizing memory use. Oh crud, this is still not getting me anywhere after two weeks.

Unfortunately, again my immutable container architecture limited my ability to see logs and SSH connections were often terminated due to low memory as well. Once I terminated the container without committing the container the logs were lost. So, I had to modify the current container to use an external volume for all the log files and now wrote them out to permanent storage.

Whoa! What do I find in the apache2 access.log after the next time the issue occurs? Well, when I did a tail of the last 200 entries I found my site was being attacked by a Googlebot, and there were a lot more entries in addition to those. In the end, I was a victim of a denial of service attack.

I believe its important to look at what data I had available and the characteristics identified by the logs and error messages. Nothing screamed DoS attack consuming mass number of threads on the Apache server and driving memory usage to 0 so that the memory manager was sacrificing threads to keep the OS alive (does that make anyone else think of Kirk screaming to Scotty, "all power to life support"?). When the attack stopped, mysqld_safe restored the thread, but it seems the socket or some other interprocess mechanism didn't allow WordPress to communicate with the MySQL.

Piecing this together after the fact required a mix of skills. It might have been easier if I was doing live monitoring and tracking inbound requests while also constantly checking that WordPress could communicate MySQL, but realistically, this is a dramatic step when all else has failed.

Through this I learned a lot about container architecture, but this issue is probably still lingering. I'm just denying all requests to access XML-RPC from outside IP addresses at this time and the WordPress has been up for over 24 hours. More importantly, it really reinforces what I wrote about in the article and I don't believe I could have reached this point if I didn't have a good understanding of the infrastructure, operating system, networking, Docker and LAMP stack.

Read the original blog entry...

JP Morgenthal is an internationally renowned thought leader in the areas of IT transformation, modernization, and cloud computing. JP has served in executive roles within major software companies and technology startups. Areas of expertise include strategy, architecture, application development, infrastructure and operations, cloud computing, DevOps, and integration. He routinely advises C-level executives on the best ways to use technology to derive business value. JP is a published author with four trade publications with his most recent being "Cloud Computing: Assessing the Risks". JP holds both a Masters and Bachelors of Science in Computer Science from Hofstra University.

@DevOpsSummit Stories

By Pat Romanski

SYS-CON Events announced today that Peak 10, Inc., a national IT infrastructure and cloud services provider, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Peak 10 provides reliable, tailored data center and network services, cloud and managed services. Its solutions are designed to scale and adapt to customers' changing business needs, enabling them to lower costs, improve performance and focus internal resources on core competencies.

May. 1, 2016 06:00 PM EDT  Reads: 1,150

By Elizabeth White

May. 1, 2016 01:30 PM EDT  Reads: 1,572

By Pat Romanski

May. 1, 2016 01:00 PM EDT  Reads: 1,749

By Elizabeth White

May. 1, 2016 12:15 PM EDT  Reads: 2,325

By Liz McMillan

May. 1, 2016 11:45 AM EDT  Reads: 1,495

By Liz McMillan

May. 1, 2016 11:00 AM EDT  Reads: 645

By Pat Romanski

May. 1, 2016 10:15 AM EDT  Reads: 983

By Elizabeth White

May. 1, 2016 10:00 AM EDT  Reads: 960

By Elizabeth White

May. 1, 2016 09:30 AM EDT  Reads: 995

By Pat Romanski

Much of the value of DevOps comes from a (renewed) focus on measurement, sharing, and continuous feedback loops. In increasingly complex DevOps workflows and environments, and especially in larger, regulated, or more crystallized organizations, these core concepts become even more critical. In his session at @DevOpsSummit at 18th Cloud Expo, Andi Mann, Chief Technology Advocate at Splunk, will show how, by focusing on 'metrics that matter,' you can provide objective, transparent, and meaningful feedback on DevOps processes to all stakeholders. Learn from real-life examples how to use the dat...

May. 1, 2016 08:45 AM EDT  Reads: 606

By Elizabeth White

May. 1, 2016 06:30 AM EDT  Reads: 2,505

By Elizabeth White

May. 1, 2016 04:15 AM EDT  Reads: 1,749

By Liz McMillan

Apr. 30, 2016 02:30 PM EDT  Reads: 1,734

By Elizabeth White

SYS-CON Events announced today that Fusion, a leading provider of cloud services, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Fusion, a leading provider of integrated cloud solutions to small, medium and large businesses, is the industry's single source for the cloud. Fusion's advanced, proprietary cloud service platform enables the integration of leading edge solutions in the cloud, including cloud communications, cloud connectivity, and cloud computing. Fusion's innovative, yet proven cloud solu...

Apr. 30, 2016 09:45 AM EDT  Reads: 2,582

By Pat Romanski

Apr. 29, 2016 07:30 PM EDT  Reads: 2,447

By Elizabeth White

Apr. 29, 2016 05:15 PM EDT  Reads: 1,737

By Elizabeth White

Apr. 29, 2016 04:30 PM EDT  Reads: 1,823

By Elizabeth White

SYS-CON Events announced today TMCnet has been named "Media Sponsor" of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Technology Marketing Corporation (TMC) is the world's leading business-to-business and integrated marketing media company, servicing niche markets within the communications and technology industries.

Apr. 29, 2016 04:45 AM EDT  Reads: 2,408

By Elizabeth White

Apr. 27, 2016 07:15 PM EDT  Reads: 2,436

By Pat Romanski

Apr. 27, 2016 04:00 PM EDT  Reads: 2,201

By Pat Romanski

Apr. 27, 2016 01:00 PM EDT  Reads: 2,020

By Liz McMillan

SYS-CON Events announced today that FalconStor Software® Inc., a 15-year innovator of software-defined storage solutions, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. FalconStor Software®, Inc. (NASDAQ: FALC) is a leading software-defined storage company offering a converged, hardware-agnostic, software-defined storage and data services platform. Its flagship solution FreeStor®, utilizes a horizontal architecture that unlocks a new world of storage opportunities, allowing IT managers, MSPs, and CS...

Apr. 27, 2016 12:00 PM EDT  Reads: 2,489

By Pat Romanski

Apr. 26, 2016 08:45 PM EDT  Reads: 1,625

By Sanjay Zalavadia

Apr. 26, 2016 06:15 PM EDT  Reads: 2,040

By Elizabeth White

Apr. 26, 2016 12:30 PM EDT  Reads: 1,968

 
Source: The Curious Case of the WordPress Docker Container | @DevOpsSummit #DevOps

No comments:

Post a Comment