Developing micro-microservices in C on Red Hat OpenShift

Click for: original source

For optimal runtime resource usage and millisecond startup times, though, it remains hard to beat C. Comparatively few people in the IT industry have experience implementing middleware components in C. This fact is ironic because C is an ideal vehicle for implementing truly micro microservices. By Kevin Boone.

This article discusses some of the implications of implementing a REST-based web service in C. My example is a component called solunar_ws that calculates sun and moonrise and sets times at any location on any day. Author has deliberately chosen an example that is self-contained, but which does real computational work. With 8,000-or-so lines of C code, this example is a good deal more complex than a “Hello, World.”

The main points:

  • About the web service
  • About the container
  • Challenges
    • BusyBox
    • Alpine dependencies
    • MUSL
    • TLS issues
  • Developing for an ultra-lightweight container
  • Testing in a virtual machine
  • Testing (and possibly developing) in a development container
  • Building the production container
    • A multi-stage container build
    • The first-stage build
    • The second-stage build
  • Deploying on OpenShift

… and more. However, as author pouints out, although it’s possible to create a tiny container, it isn’t necessarily advisable. . In particular, this container image has no diagnostic tools of any kind. In addition, examining a core dump from a container like this will be an unhappy experience for anyone without a development environment that perfectly matches the container’s base layer. You will also get access to GitHub repository for the complete source code. Excellent read!

[Read More]

Tags microservices web-development app-development performance devops cloud