Running a Python 3 REST application with Statsd and Consul support in Docker

Where I currently work we build a lot of RESTful services in either Go (golang) or Python. Many of these services are deployed to Apache Mesos via Docker containers with everything tied up nicely using tools like Marathon and more. For our Mesos based services we also like to track metrics as well as have these services load their configurations from Consul which in turn helps keep our services as ephemeral as possible.

Today, I’m going to go over setting up a very simple way to spin up a Python Falcon REST service that reports to Statsd as well as registering as a service with Consul along with setting up health checks. I’ve borrowed some ideas/code from several places and changed as needed.

Continue reading

Posted in Open Source, Python | Leave a comment

Fixing a Race Condition using a Mutex with Go (golang)

I was recently reading some articles on Go (golang) and it it got me to trying out a few techniques. New gophers may not know but Go allows you to compile your code to detect race conditions. Google has even implemented it into Go’s continuous build process where it will catch race conditions as they may get accidentally injected. Today I’ll show a simple example of how to check for race conditions in your Go code and along the way we will fix those race conditions using a Mutex.

Continue reading

Posted in Go, Open Source | 2 Comments

A Look at two Python Plugin Managers: Stevedore and Pike

If you’ve worked with OpenStack code for even a minimal amount of time you’ve probably come across a Python plugin library called stevedore (you can find the latest docs here). The second Python plugin manager I’m going to cover is one called Pike (latest docs can be found here) which had it’s beginning in a project I blogged about (here and here) a while back called Pynsive. Let’s go over some example code to get a basic idea how each of these work.

Continue reading

Posted in Open Source, OpenStack, Python | Leave a comment

Trying out the Docker Compose support for PyWebhooks (a Python 3 webhooks server project)

When I introduced PyWebhooks I wrote an article on how to get started trying out the service easily using Vagrant. It was always my plan to add Docker Compose support to PyWebhooks to make it even easier for someone to try out PyWebhooks. In this article I’ll walk you through the steps to use the recently added Docker Compose support.

Continue reading

Posted in Open Source, Python | Leave a comment

Adding a Marathon health check to your Python 3 Mesos application

My last article showed you how to deploy a Python 3 Application to an Apache Mesos Cluster using the Marathon API. I just wanted to do a quick follow-up on how you can easily add a Marathon HTTP health check for your application.

Continue reading

Posted in Apache Mesos, Open Source, Python | Leave a comment

Deploy a Python 3 Application to an Apache Mesos Cluster using the Marathon API

Where I work we are actively using Apache Mesos to deploy our production applications written in Go, Python, Lua, etc. We also use Chronos and Marathon. In this article I’ll show you how to setup a local Mesos Cluster complete with Marathon (using Docker) and how to build a simple Python 3.x application to deploy into it.

Continue reading

Posted in Apache Mesos, Open Source, Python | Leave a comment

Build a Python Microservice with Amazon Web Services Lambda & API Gateway

I think in many ways AWS (Amazon Web Services) is a game changer for the entire “cloud”. Many companies base all or some of their infrastructure on AWS. Today I want to kick off an AWS Lambda tutorial from a Python developer’s perspective. Since the past year the Python code I write my articles have been done in Python 3.x however today’s article is an exception since the actual hosted Lambda Python code has to be Python 2.7 since that is what AWS Lambda currently only supports (Jan. 2016). Regardless of having to use Python 2.7.x AWS Lambda is very cool to work with and has a lot of potential to make some very useful services.

Continue reading

Posted in Amazon Web Services, Python | 4 Comments

Deploy a Go (golang) application to a minimal sized Docker container

Docker and Go have both been getting a lot of attention and rightfully so for the particular problems each one solves. Today I’m going to focus on something each technology does very well and that is building an application that is built with no external dependencies and is easy to deploy. Of course this example will be very scaled down so the article itself doesn’t get so long that readers lose interest but it is enough to extend from for those that want to take it to the next step.

Continue reading

Posted in Go, Open Source | 2 Comments

Fetching a remote configuration using Consul and Go (golang)

Nowadays its pretty common to spin up a Docker container that will run an application to do some sort of work or processing. Many times this application requires some sort of configuration to set it up correctly to run. With Docker and an app built in Go (or any other language) you could spin up the container and set an environment variable which the application could then read. Let’s assume the environment variable is just an address that points to something like ectd or Consul where the full configuration settings are stored. Let’s go over how this can be done using Go (golang – excuse the redundancy on Go/golang I use this to help the search engines out).

Continue reading

Posted in Go, Open Source | 2 Comments

Building a self-contained Python 3 application using PyPy

A few articles ago I showed you how to create a Python 3 Microservice (a simple Minecraft service). At the end of that article I mentioned in the future I’d show you how to build a self-contained Python application/service. Well, today is that day.

I’ll use PyPy (the Python 3.2.5 compatible PyPy3 2.4.0 version) to show how this can easily be done and how you can install packages into the self-contained instance of Python. What this means is you easily package this up and simply extract it to another machine (same architecture or you need to modify some steps) and it will just run even if Python is not installed there. In fact there are several ways to do what I’m going to show you how to do today and several ways to package this up. I’m just going to focus on one possible way to do this as easily as possible.

Continue reading

Posted in Open Source, Python | Leave a comment