Multiple sessions accessing localhost database

I do not how to ask the question, but I am confused by how to manage sessions when the server is at local host.

Accessing the database direct
Without a middleware (REST), sessions are created as soon as you connect to the database. Even 2 connections from same computer gets 2 separate sessions.

session1

Accessing via Go and localhost (127.0.0.1)

Using Golang as middleware, all connections go through 127.0.0.1 and there will be only 1 single session.

session2

My questions are

  1. Is there any way to pass the cookie to Go in order to create separate database sessions?

  2. Or is this the way it should be?

Any clue to handle this is appreciated.

Well, i don’t kow exactly what does your application do but generally speaking separate sessions mean separate environments for your services, and that’s good. I think a common session on middleware for many services, excepting a few cases (like authentication), can be problematic from various reasons(i don’t know… what happen if that session expires… lose all endpoints?, hang or whatever, concurrency issues, return the results, etc).
:thinking:

General CRUD stuff. Theoretically you can access the database by using a public ip-address and automatically get the sessions you need. But what is the point with REST if the database is public?

The built in connection pools does the trick. Done some quick test and it seems to work.

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