Database selection for master server

Hi

I am interested to hear your idea about which database you would suggest for master server.

(Note I am developing the master server with Spring Boot and REST API. )

  • Relational DB

    • MySQL
    • PostgreSQL
    • HSQLDB
    • …?
  • NoSQL

    • MongoDB

How?

  • Embedded (server-less running within the app)
  • Standalone server

Regards

2 Likes

I’ve only ever really used PostgreSQL (as standalone server), so I can’t tell you how it compares to others; what I can tell you is that I’ve been happy with it over the years, it would be a solid choice.

1 Like

I just use MySQL/MariaDB - but I generally dev enterprise, so…

3 Likes

If you ever want to scale stand alone is the only option i guess. imho its also one of the easiest ressource to outsource if the db is a bottleneck. sql/nosql depends usually what kind of data you want to store.

mongo/boot/rest seems a pretty common choice nowadays. dont know if its just a buzz thing or…

1 Like

Usually, any data required by master server for services like:

User Login
User Profile
Wallet
Item Store
Registering/listing public game servers
Friends
Lobby
Leaderboard/Scoreboard
News
… so on.

I use CockroachDB - a scalable, PostgreSQL compatible, distributed database: https://www.cockroachlabs.com/

It’s by far the easiest clustered DB that I’ve ever set up and run. If you’re going stand-alone, I highly recommend it.

If you need more for clustering than just a shared database (real-time communication between servers, for example), you might want to take a look at Apache Ignite: https://ignite.apache.org/. You can embed it directly in your server as a library, and you can also use it with a traditional RDBMS by implementing the CacheLoader/Writer interfaces. This is the architecture we’re moving onto at MyWorld, and we may end up making much more use of Ignite’s built-in SQL capabilities.

2 Likes

We were using PostgreSQL back in university as it was academic.

I am currently following this tutorial

and the author using MySQL in the course, which made me give it a search and found a bunch of games like Minecraft using it as well.

For game server (note game server is separated from master server) I am using HSQLDB for persisting entity states in ES as it is used by default in ZayES. It is extremely fast because of the in-memory data load. So I thought it might be a good option for the master server as well, but I might be wrong.

On the other hand, seems MongoDB has also gained some interest.

1 Like

Yeah, I saw your blog post on their website yesterday. That was nice :slightly_smiling_face:

I guess CockroachDB is a bit too much for my need ATM. I am yet at the learning phase thus things may go different in the future so I will remember it. Thanks

Interesting, going to take a look at it. Thanks again.

1 Like

For REST calls that return JSON, it’s hard to recommend anything but mongoDB. It’s literally a JSON based database… even the queries are JSON.

I love mongoDB for REST. 90% of the REST methods end up being stupidly trivial.

For a “real SQL database”, I’m a big fan of PostgreSQL and would never touch mySQL in a million years. Like, why have any of those limitations when postgres is right there? Postgres is a breath of fresh air from either Oracle or mySQL to me.

…but if I’m rolling a new REST service, mongo is what I reach for.

3 Likes

@pspeed how you handle object relations like one-to-many. Do you embed them in one collection or use separate collections and reference documents by ID?

Edit:
Sorry if it sounds a stupid question. :slightly_smiling_face:

It depends on what they actually are.

But note that true REST has already put restrictions on how ‘resources’ are related. If you are following true REST principles then mongoDB is pretty much a drop-in storage solution.

1 Like

I found MySql quiet populer last year. I don’t know why. https://en.wikipedia.org/wiki/DB-Engines_ranking . However I think NoSQL is something lately. There are choices I think. for example maybe I want to try neo4j.

1 Like

Try embedded nosql database iBoxDB, get new program experiences.
​here is the benchmark with mysql.

https://github.com/iboxdb/teadb

I use a combination of MySql and Apache Cayenne which is an OR mapping tool that also generates HTTP remote access client classes that you can configure to be read only. This allows the client to pull up read only data without the need for spidermonkey. Spidermonkey is reserved for entity management and positional data sync. Cayenne/MySql is also used for retrieving user created assets at runtime (For example, when users design their own ships in game).

I use several different databases for work. I have had amazing luck with postgres. Its performance is hard to beat, and the feature set is has is great. Also, it is very simple to setup. And if you need scalability, it has many options for that.

Also Postgres has long had JSON and JSONB datatypes and features if it is hard to decide over MongoDB.

SQL + JSON != MongoDB.

Not even close to the same thing… it totally misunderstands the fundamental level that Mongo is a JSON database.

…unless postgres lets you query subdocuments from JSON blobs using JSON and I missed it. This didn’t even work properly with XML and XPath last I tried… so I have doubts.

Edit: and don’t get me wrong, I’m a giant postgresql fanboy. It’s my favorite relational database by a long shot. But fitting it to JSON-based (proper) REST calls is a LOT (a lot a lot) more work than mongo.

1 Like

I do not know about querying json using json, it is a SQL database, but you can select query json blobs.
https://www.postgresqltutorial.com/postgresql-json/

I personally do not ever do this, I use mostly postgres UDTs to create object oriented databases, and map them to POJOs using pgjdbc-ng SQLData mappings when I need such functionality.

For most applications I just make normal databases and create JPA entities to map them, or even let JPA create the database.

And to re-enforce what @pspeed said, postgres does not have all the same features as mongodb, but personally, I will always choose postgres over mongo after my experiences with maintaining mongo databases. Mongo is not a relational database and should not be used as such, it is great as long as you keep that in mind.

1 Like

Thanks so much guys for all your helps, I decided to use MongoDB for my REST application.

Guys, I have a question.

In REST there are 4 resource archetypes:
Document, Collection, Store, and Controller

I can understand what Document, Collection and Controller resources are, also, I can see how the concept of Document and Collection in REST and MongoDB are related. But I do not understand what Store archetype is. :man_shrugging:

I read that they are client managed resources. But this does not make sense to me. Can someone please explain the Store archetype in a bit more details with an easy to understand example.

Regards

Edit:
Also sorry if this is offtopic/not JME related. :sweat_smile: