Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Npstr6576yNumbers look fine to me. It depends somewhat on what kind of data you are touching but generally speaking, 75% writes is not exactly optimal for SQL, as well as using caches, so don't be surprised about a meh performance.
Also run a profiler to find out where the time is actually spent. -
mojo20127836y@Npstr I‘m not using any hibernate 2nd level cache btw.
A typical payload looks like:
POST /v1/models/party HTTP/1.1
Host: localhost:19000
Content-Type: application/json
Authorization: Basic YWRtaW46TUQ1OmVlMTBjMzE1ZWJhMmM3NWI0MDNlYTk5MTM2ZjViNDhk
{
"title": "spOt test party",
"motto": {
"en": "Let's do it",
"de": "Auf geht's",
"typeCode": "localizedstring"
},
"location": {
"typeCode": "useraddress",
"streetName": "Test street",
"streetNumber": "100",
"city": "Vienna",
"postalCode": "1030",
"country": "at"
},
"invitedGuests": [
{
"typeCode": "user",
"id": "guest-01@test.at",
"shortName": "Guest user #1"
}
]
} -
Npstr6576yLooks like you have a bunch of entities in one-to-many / many-to-many relationships? This means writes will be split in several statements (can't do much about that). And reads most likely too (you can optimize hibernates queries but then you might as well not use it at all).
Imo at this point you should be looking at the queries Hibernate is generating, as well as the aforementioned profiling, to understand what's going on there. And please read this: https://toptal.com/java/... -
mojo20127836y@Npstr yeah its gonna 3 inserts in that statement, but I think it can only be further optimized by either using native queries or joql insert queries but that would be alot of effort to still aupport generic entities 😫
-
matste6416yAre you sure it’s hibernate and not the database being the bottleneck? What kind of profiling have you done?
You need to inspect the sqls you produce. Depending on the framework you use, it’s something like hibernate.show_sql=true
Then you can think of enabling batch inserts: https://vladmihalcea.com/how-to-bat... -
mojo20127836y@matste I‘ve not investigated at the mysql level, but u might be right. I already use batch inderts but its only a partial cure as on each request a new persistence context (and transaction) is opened.
-
mojo20127836y@matste when I insert data with my custom inport language (impex) i can easily batch insert 10k user entities in a few seconds. Thats because hibernate can use all kinds of tricks when only one persistence context is used (like vlad explains in ur link)
-
matste6416yAlso, 350 concurrent requests is a super high number for a single JVM. Are you sure you are not blocked by some connection pool, making your requests actually wait in a queue? The default connection pool for Hibernate is set up to size of 20 (actually, the default cp is rarely used).
When I worked on a pretty powerful postgres machine (32 cores), the connection pool was set up to something like 50. -
mojo20127836y@matste that might be it, with 500 i get soxket timeouts. So jetty seems to be out of threads too.
I was thinking of going async, but I would have to migrate fromspsrk to javalin 😐
But the db connection is a good tip, that might be it, I‘ll try it and report back. Btw the project Im talking sbout is https://spot-next.io
Related Rants
Hey guys, who has experience with JPA/hibernate RESTful performance numbers.
Interesting would be:
* persistence operations per second, and the response times
* proportion between read/write for a typical rest service
Rightnow i get ~300ms read, 900ms write at 350 concurrent requests. 75% write operations
I more or less ruled out my custom code, problem seems to be hibernate (of course ...😋)
Stack: jetty, jackson, hibernate, mysql
rant
jetty
hibernate
rest
statistics
performance