B4J Tutorial jServer & SQLite [Multiple Request Stress Test]

OliverA

Expert
Licensed User
Longtime User
concurrency
Concurrency can be a tricky thing. If SQLite processes request efficiently enough sequentially, concurrency is not really an issue (depending on workload/environment). In my own testing, SQLite (using it via jRDC2) was not the bottleneck, but my own gigabit-speed LAN was.

Running jRDC2 on a bench computer consisting of a Celeron, 4GB RAM and 64GB (32?) SSD, simulating 30 clients (not running on the server) hammering the server with inserts for 60 seconds, I was able to create over 14K records. Each record contained a JPG of ~ 30KB. Without the images, 10 clients hammering the server were able to create 90K records (albeit small records). So whatever concurrency may be missing from SQLite may not be an issue depending on the type of workload it is asked to take care of.

Using MySQL (and pooling), 15 clients hammering with no PICs created 78K records. 20 clients hammering with pictures created over 12K records. H2 as a backend (using pooling), 15 clients created 15K records with pictures and 83K records without pictures.
 

OliverA

Expert
Licensed User
Longtime User
but to the risk of accessing the same data by multiple users without the necessary blocking.
Reading is not an issue, and writing was solved with WAL mode
 

j_o_h_n

Active Member
Licensed User
Those numbers for sqlite look insanely good to me particularly since writing requires exclusive control.
It also tells me how little I know about the capacity of databases
I'm using postgresql as the backend for a jserver that probably will never receive more than a few requests per second if it gets busy
and I was worrying about how it would cope!
BTW I would love to see you expand this to other databases especially postgres and mysql if possible (off topic I know feel free to ignore)
 
Last edited:

tchart

Well-Known Member
Licensed User
Longtime User

@j_o_h_n exactly what I was trying to show. A lot of developers will just instinctively use a full blown RDBMS for a small application. It just complicates things and is usually not required.

I've been using enterprise databases for 20+ years (Oracle, SQL Server, Postgres etc). I'm even certified for SQL Server but it's not my go to for most applications.

In most cases there is no advantage in going for a full blown RDBMS and it generally will land you with more admin overhead for little gain. This is especially the case if you are not familiar with configuring and administering these databases.

As also mentioned there are some other options besides SQLite, like H2, which offer an easier pathway to a full blown RDBMS through compatibility modes. This can make scaling an app much easier if you find you need to.

But for any of my apps I have not hit any road blocks with SQLite - and I can tell you for experience that my customers appreciate not having to deploy yet another database when they install my apps.
 

ilan

Expert
Licensed User
Longtime User
@tchart thank you very much for making those tests. i just accidentally saw this thread. i guess that if you include a member with @ he does not get any notification about it.

i also made some tests and found out that SQLite is really powerful especially if u have a lot of entries you want to perform and use

B4X:
BeginTransaction

running 1000 inserts in a loop would take about 8 seconds but doing it like this:

B4X:
    SQL1.BeginTransaction
    Try
        'block of statements like:
        For i = 1 To 1000
            SQL1.ExecNonQuery("INSERT INTO table1 VALUES(...)
        Next
        SQL1.TransactionSuccessful
    Catch
        Log(LastException.Message)
        SQL1.RollBack 'no changes will be made
    End Try

took me few ms.

i think for a small-middle eCommerce site SQLite can be a reliable choice. although some limitations did make me think again if i should use it or not.

like the much lower dataType i can use and the fact that you cannot make 2 calls to the db at the same time so each call blocks the db (as far as i have understoud)
but again i am working on a ecommerce site so it should be fine enough.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…