Glenn Engstrand

Disillusioned with Java, many small startups are considering either Python or Node.js for their micro-services. This blog can help you decide which is right for you. I will explore what it is like to develop a rudimentary news feed micro-service written in version 3 of Python on Flask by comparing that experience with developing the same micro-service in Node.js

Questions and Answers

In the peer review process for the document below, people have asked these questions.

Q: You mentioned tornado and gevent but what about gunicorn and twisted web? Aren't those server backends available too?
A: They are available for Flask but not for Connexion.
Q: If Flask supports more server backends, then why not just code to Flask? Why bother with Connexion if it is going to limit you?
A: Connexion is the integration with Swagger which accelerates your time to value by automatically generating all the HTTP parts for both clients and server. In order to be a fair comparison, both services needed to have feature parity. Since the node.js service had a swagger integration, the python service had to have a swagger integration too.
Q: You mentioned that only one MySql driver would work with Python 3 and SQL Alchemy. Which driver was that?
A: Precisely version 2.0.4 of the MySql Connector for Python. The latest versions had problems.
Q: Why didn't you test the Flask server running both multi-threaded and multi-process?
A: I tried but that configuration is not supported. It wouldn't even start.
Q: Why not just run a second instance of feed5 on the same server but listening to a different port and have kong proxy requests to both?
A: Because then feed4 and feed5 would have different deployments which would be an unfair comparison.
Q: Where can I find the outbound post source code for feed 4 and feed 5 that you compared?
A: here and here
Q: What is cluster mode?
A: A single instance of Node.js runs in a single thread. To take advantage of multi-core systems the user will sometimes want to launch a cluster of Node.js processes to handle the load. The cluster module allows easy creation of child processes that all share server ports.
Q: What is Business Driven Development?
A: Your unit tests are written more like a Domain Specific Language in the problem domain of the business.

Referenced Open Source Projects

Here are the links to the projects referenced in the document below.

project description
Cassandra NoSql database
Chai javascript mocking library suitable for use in unit tests with node.js apps
Connexion Flask integration with Swagger
Docker run micro-services in containers
Elastic Search keyword based search engine
Flask Micro-service framework
Flask Sql Alchemy Flask integration with SQL Alchemy
Flask-Testing Flask unit testing framework
Kafka cluster aware message broker
Mockery Mocking library for Node.js unit tests
Node.js micro-service framework for javascript developers
Node Package Manager Use this to install dependencies for and start Node.js services.
pip Use this to install dependencies for python services.
pycharm IDE for Python
Python programming language used to develop the feed 5 micro-service
Redis external memory cache
Sql Alchemy Python SQL Toolkit and Object Relational Mapper
SqLite single user SQL database that can plug into SQL Alchemy for unit tests
Swagger MDSD for APIs
Swagger-Tools Node.js swagger integration
WebStorm IDE for Node.js

Python Flask vs Node.js