Go, my new 'Perl' for backend web dev

For many years (20+), I have been developing and hosting web sites and web apps on various web servers running Apache with a number of virtual hosts. I have always used Perl for backend work (mysql/security etc). So one of my apps/sites might have a 100 or more Perl script in a /cgi directory that get called from javascript on the client in order to populate the browser page - usually via ajax.

Perl is no longer as useful as it once was, support and libraries are not so common, so it became clear I needed to change. I looked at other scripts - Python etc - but realised after researching a few that Go would be a great language to switch over to. I spent some time learning it and growing to appreciate all its qualities.

But when it came to using it as a replacement for Perl, it very soon became obvious that it wasn’t to be a straight swap. Writing dozens of Go apps for a website is obviously not the way to go. Most of the articles I found were talking about Go being used to write servers running on a different port with a mux and various handlers for the various ajax calls - and not to be called from Apache. My sites/apps make heavy use of js/css/scss and some frameworks (Bootstrap etc)

So, I get that idea - I need a Go app (server/daemon) to listen for all calls on a different port - say 8080 - then do the backend work, and then deliver the results back to the client.

This is where I am struggling to understand the way to proceed …
If I have many virtual hosts managed by Apache, do I need to be running one Go server app (daemon) for each site/app that I am hosting … and each one listening on a different port (8080, 8081, 8082 … etc) …

I have spent so much time searching for guidance/answers … but not found a single reference to this situation - every article I found talks about a Go server/daemon. Can anyone point me in the right direction, please?

Welcome to GolangBridge :rocket: :fireworks:

This query depends on your overall architecture and program. The design you mentioned is “reverse proxy and services” approach (Apache acts a reverse proxy and each site/app has its own dedicated server owning a port number).

What I can tell you is that Go server can work in both Apache’s role (1 big fat app), and as the dedicated “service” server. Hence, you do not need to throw away your existing Apache system. The point is Go can operate without Apache/Nginx, if the requirements allow.

I can’t decide for you because it is a design question. Perhaps cross-checking with your requirements and resources can shed some light.

You’re seeking a system design question, not a specific Go programming language query. Will these keywords help in your next search?

deployment go server strategy production
2 Likes

Yes, do whichever makes most sense to you.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.