Search code examples
mysqljsonperformanceprocessing-efficiency

MySQL database or a simple JSON file which one will be performance efficient and storage efficient?


Let's put concept on table first. I have voice assistant type of feature for my website.

How that works?

  • User will type some random phrase and hit enter.
  • That phrase will go to A REST API (having AI capability on server) it will decide user intent behind that phrase and respond with some relevant text.
  • I will be converting that text in to a speech, say mp3 file.

Flow of converting text to speech:

  • Received text check against a Javascript collection of object
  • If phrase found in that then play speech file using path in that object.
  • if not found make an Ajax request to local server and call text to speech third party API to receive binary data which can be stored as mp3 file.

  • Store path of that file, text and timestamp. (Which can be used in Js collection of object)

Now the questions are:

  • Should I use MySQL to handle that?

  • or should I use simple JSON file for it?

  • Which way is efficient from storage and speed point of view?

Note:

  • if I use MySQL (Please do not suggest to change) then I will need to restrict number of phrase record to 200 entries.
  • I am concerned with ease of, minimum time for process and load of that process.
  • We have to take amount of time end user will be on wait until this process take place to hear received text in a form of speech

Solution

  • These are the biggest processors:

    • AI
    • Text to MP3
    • MP3 to text

    Any database is very far down the list of concerns. It sounds like your system might execute 1 query-per-second. Performance issues don't start until 100 or 1000 qps.

    As for storage:

    • 100-1000 bytes for meta information, versus
    • 10K-100K bytes for MP3 (input or output)
    • 100GB-1TB for typical low-end server

    So, who cares whether MySQL datbase or JSON file is 'bigger'.