To understand the rules for port binding and stand-alone applications, itβs useful to look at things in terms of platforms designed to run applications with 12 factors, such as Heroku or Deis .
These platforms scale applications at the process level. When processes scale, the platform tries to place these additional workers behind the routing grid so that they can begin to serve traffic. If the application is not self-sufficient and, for example, is closely connected with the Apache server interface using mod_jk , it is impossible to scale by launching more isolated workflows.
Port binding exists to solve the problem of "port mediation" at the platform level. If every application employee listened on port 80, conflicts would arise. To solve this problem, port binding is the convention that an application listens on a port allocated by the platform and that is passed as the $PORT environment variable. This guarantees: a) the application worker is listening on the correct port and b) the platform knows where to direct traffic intended for this worker.
source share