1.8.8 REST API vs Direct Database

Discussion in 'Spigot Plugin Development' started by Gustavo_kio, Mar 10, 2020.

?

What should i do?

  1. Keep with REST

    5 vote(s)
    100.0%
  2. Connect directly with the Database

    0 vote(s)
    0.0%
  1. So, I'm here today to ask your opinion.

    I currently have the following structure:

    SomeApp -> service -> MainApp -> REST API -> Database

    SomeApp: A specific plugin.
    Service: Vault (sometimes the service is not used and the request goes directly to the MainApp).
    MainApp: The main plugin handling everything on the server.
    REST: Http request api
    Database: mongodb or mysql

    My questions are:

    1. Should i keep doing this way or should my mainapp connect directly with the database?
    a. If so, isn't a bad thing to have more than one app querying the database? Because now i have control of everything that's being changed.
    2. Do you have other suggestions?


    I'm doing that bcz i want to have access to the data on other servers/places.
     
  2. I'm neither a MongoDB user nor a MySQL user, but...

    What does "connect directly" mean in the context of MySQL? Doesn't it already run in its own process? If so, then having some kind of "connection" to it is still remoted, relative to the database itself. I assume MySQL will handle concurrent access correctly, so it probably doesn't care whether a connection is from the same machine.

    That said, if you're expecting to connect to the database from other servers too, then, from a consistency perspective, it might make sense to continue using your REST solution from everywhere. Unless MySQL already has APIs for connecting remotely, then I'd use those.
     
  3. So. Maybe i didn't explain well. Connecting directly to mysql would mean taking the REST out of the equation.

    Pros: It'll be faster to query and develop
    Cons:
    - I won't have control of the data.
    - If for some reason i change the structure of the database, or decide to log stuff, etc. I'll have to do everything on every server (mainapp).