understanding good practice for java rmi -
i have rmi application, every request client, created new connection (on server side) database, r n sql query , turned data serializable class sent client.
the user base of app grew,and request took long time complete. solution previous programmers came create fixed size connection pool server db, , every client's request used oldest(the 1 used least recently) run sql query. question is: correct way solve such problem?
i say, pooling db connections important step, since establish connection expensive. instead of implementing own pool use existing , proven pooled datasource implementation such dbcp or c3p0. have many useful features such vaying size, automatic connection check, etc...
if query istself takes long, optimisation more complex that. various approaches possible , depend on details of situation, example :
- is there 1 sql query, same, question seems imply ?
- is database read-only ?
- if not, modifications made within same application or externally ?
- etc...
possible approaches (i can think of right now) reduce request time :
- caching of result in java app (but vast subject...)
- optimisation of sql request
- optimisation of db schema, indexes or deeper refactoring of tables structure
- reduce amount of data sent client bare minimum (in case network bottleneck)
i hope helps. need more details on use case give better answer.
Comments
Post a Comment