Thread: Postgres and Java Microservices Multithreading

Postgres and Java Microservices Multithreading

From
Date:

Hi Experts,

 

To set the context we are operating in Oracle 11g R2 and our applications are deployed in private cloud and all 15 +  Java micro services are multithreaded.

 

And we are doing database migration from Oracle 11gR2 to Postgres 12.

 

So if anyone can share your experience or share some documentations/use cases if  we can maintain the same configurations for Java micro services with multithreading as we are using in Oracle and same works in Postgres too? – (We just plan to switch the data source from Oracle to Postgres- will that work? )

 

 

Thanks..

 

RE: Postgres and Java Microservices Multithreading

From
Date:

Hi Experts,

 

Please let me know if you have some use cases or documentations around this.

 

Any response will help me a lot in this context.

 

Thanks in advance.

 

 

From: Bhattacharjee, Soumik
Sent: woensdag 4 december 2019 14:34
To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; pgsql-admin@postgresql.org
Subject: Postgres and Java Microservices Multithreading

 

Hi Experts,

 

To set the context we are operating in Oracle 11g R2 and our applications are deployed in private cloud and all 15 +  Java micro services are multithreaded.

 

And we are doing database migration from Oracle 11gR2 to Postgres 12.

 

So if anyone can share your experience or share some documentations/use cases if  we can maintain the same configurations for Java micro services with multithreading as we are using in Oracle and same works in Postgres too? – (We just plan to switch the data source from Oracle to Postgres- will that work? )

 

 

Thanks..

 

RE: Postgres and Java Microservices Multithreading

From
Date:

Hi Experts,

 

Few more details as discussed with application team.

 

In parallel processing Application will create multiple threads towards our PG database to retrieve/ update data.

 

 

  1. Application will send multiple parallel requests to DB on same table to SELECT data.
  2. Application will send multiple parallel requests to DB on same table to UPDATE data
  3. Application will send multiple parallel requests to DB on same table to INSERT data

 

 

 

Thanks..

 

From: Bhattacharjee, Soumik
Sent: donderdag 5 december 2019 10:48
To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; 'pgsql-admin@postgresql.org' <pgsql-admin@postgresql.org>
Subject: RE: Postgres and Java Microservices Multithreading

 

Hi Experts,

 

Please let me know if you have some use cases or documentations around this.

 

Any response will help me a lot in this context.

 

Thanks in advance.

 

 

From: Bhattacharjee, Soumik
Sent: woensdag 4 december 2019 14:34
To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; pgsql-admin@postgresql.org
Subject: Postgres and Java Microservices Multithreading

 

Hi Experts,

 

To set the context we are operating in Oracle 11g R2 and our applications are deployed in private cloud and all 15 +  Java micro services are multithreaded.

 

And we are doing database migration from Oracle 11gR2 to Postgres 12.

 

So if anyone can share your experience or share some documentations/use cases if  we can maintain the same configurations for Java micro services with multithreading as we are using in Oracle and same works in Postgres too? – (We just plan to switch the data source from Oracle to Postgres- will that work? )

 

 

Thanks..

 

Re: Postgres and Java Microservices Multithreading

From
"Peter M. Groen"
Date:
There is no reason why it shouldn't work as long as you use the database only as a data storage and all the java-stuff is as a separate layer in your software.
Conversion problems can happen on data-types, constraints and/or triggers. If you use stored-procedures, those should be converted / rewritten as well..

A bit of a strange question as this is basic datbase knowledge.... ??/ Esp. if you're working at KPN.
-- 
Open Systems Development B.V.
Peter M. Groen
Managing Director
Rooseveltstraat 18-P
2321 BM Leiden
+31 6 12 08 95 62
skype : peter_m_groen

On Thu, 2019-12-05 at 12:22 +0000, soumik.bhattacharjee@kpn.com wrote:

Hi Experts,

 

Few more details as discussed with application team.

 

In parallel processing Application will create multiple threads towards our PG database to retrieve/ update data.

 

 

  1. Application will send multiple parallel requests to DB on same table to SELECT data.
  2. Application will send multiple parallel requests to DB on same table to UPDATE data
  3. Application will send multiple parallel requests to DB on same table to INSERT data

 

 

 

Thanks..

 

From: Bhattacharjee, Soumik
Sent: donderdag 5 december 2019 10:48
To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; 'pgsql-admin@postgresql.org' <pgsql-admin@postgresql.org>
Subject: RE: Postgres and Java Microservices Multithreading

 

Hi Experts,

 

Please let me know if you have some use cases or documentations around this.

 

Any response will help me a lot in this context.

 

Thanks in advance.

 

 

From: Bhattacharjee, Soumik
Sent: woensdag 4 december 2019 14:34
To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; pgsql-admin@postgresql.org
Subject: Postgres and Java Microservices Multithreading

 

Hi Experts,

 

To set the context we are operating in Oracle 11g R2 and our applications are deployed in private cloud and all 15 +  Java micro services are multithreaded.

 

And we are doing database migration from Oracle 11gR2 to Postgres 12.

 

So if anyone can share your experience or share some documentations/use cases if  we can maintain the same configurations for Java micro services with multithreading as we are using in Oracle and same works in Postgres too? – (We just plan to switch the data source from Oracle to Postgres- will that work? )

 

 

Thanks..

 

RE: Postgres and Java Microservices Multithreading

From
Date:

Thanks Peter for your response, appreciate much.

 

But I think the applications wont behave the same way as with Oracle.(We have 15+ Microservices running in Oracle with parallel processing)

 

Below I just checked and testing in Test Env.

 

https://www.postgresql.org/docs/12/parallel-query.html

https://dzone.com/articles/postgresql-connection-pooling-part-1-pros-amp-cons

 

 

If anyone have some use cases/real time project executions  will be really helpful.

 

Thanks..

 

 

 

From: Peter M. Groen <peter@osdev.nl>
Sent: donderdag 5 december 2019 13:30
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>; pgsql-admin@lists.postgresql.org; pgsql-admin@postgresql.org
Subject: Re: Postgres and Java Microservices Multithreading

 

There is no reason why it shouldn't work as long as you use the database only as a data storage and all the java-stuff is as a separate layer in your software.

Conversion problems can happen on data-types, constraints and/or triggers. If you use stored-procedures, those should be converted / rewritten as well..

 

A bit of a strange question as this is basic datbase knowledge.... ??/ Esp. if you're working at KPN.

-- 

Open Systems Development B.V.

Peter M. Groen

Managing Director

Rooseveltstraat 18-P

2321 BM Leiden

+31 6 12 08 95 62

skype : peter_m_groen

 

On Thu, 2019-12-05 at 12:22 +0000, soumik.bhattacharjee@kpn.com wrote:

Hi Experts,

 

Few more details as discussed with application team.

 

In parallel processing Application will create multiple threads towards our PG database to retrieve/ update data.

 

 

  1. Application will send multiple parallel requests to DB on same table to SELECT data.
  2. Application will send multiple parallel requests to DB on same table to UPDATE data
  3. Application will send multiple parallel requests to DB on same table to INSERT data

 

 

 

Thanks..

 

From: Bhattacharjee, Soumik
Sent: donderdag 5 december 2019 10:48
To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; 'pgsql-admin@postgresql.org' <pgsql-admin@postgresql.org>
Subject: RE: Postgres and Java Microservices Multithreading

 

Hi Experts,

 

Please let me know if you have some use cases or documentations around this.

 

Any response will help me a lot in this context.

 

Thanks in advance.

 

 

From: Bhattacharjee, Soumik
Sent: woensdag 4 december 2019 14:34
To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; pgsql-admin@postgresql.org
Subject: Postgres and Java Microservices Multithreading

 

Hi Experts,

 

To set the context we are operating in Oracle 11g R2 and our applications are deployed in private cloud and all 15 +  Java micro services are multithreaded.

 

And we are doing database migration from Oracle 11gR2 to Postgres 12.

 

So if anyone can share your experience or share some documentations/use cases if  we can maintain the same configurations for Java micro services with multithreading as we are using in Oracle and same works in Postgres too? – (We just plan to switch the data source from Oracle to Postgres- will that work? )

 

 

Thanks..

 

Re: Postgres and Java Microservices Multithreading

From
Scott Ribe
Date:
"parallel query" refers to parallelism within a single query, not at all related to the questions you're asking

connection pooler is something you might want to investigate, but that really depends on total number of connections
acrossyour microservices, and how connection pooling within your clients might be handled. If your clients make
persistentconnections, and they're not making all that many (maybe not more than 10-20 each across the 15), you
wouldn'tneed it. If client connections come and go, or your clients use higher number of connections, then yes, put
pgbouncerbetween clients & PG. 

--
Scott Ribe
scott_ribe@elevated-dev.com
https://www.linkedin.com/in/scottribe/



> On Dec 5, 2019, at 6:22 AM, <soumik.bhattacharjee@kpn.com> <soumik.bhattacharjee@kpn.com> wrote:
>
> Thanks Peter for your response, appreciate much.
>
> But I think the applications wont behave the same way as with Oracle.(We have 15+ Microservices running in Oracle
withparallel processing) 
>
> Below I just checked and testing in Test Env.
>
> https://www.postgresql.org/docs/12/parallel-query.html
> https://dzone.com/articles/postgresql-connection-pooling-part-1-pros-amp-cons
>
>
> If anyone have some use cases/real time project executions  will be really helpful.
>
> Thanks..
>
>
>
> From: Peter M. Groen <peter@osdev.nl>
> Sent: donderdag 5 december 2019 13:30
> To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>; pgsql-admin@lists.postgresql.org;
pgsql-admin@postgresql.org
> Subject: Re: Postgres and Java Microservices Multithreading
>
> There is no reason why it shouldn't work as long as you use the database only as a data storage and all the
java-stuffis as a separate layer in your software. 
> Conversion problems can happen on data-types, constraints and/or triggers. If you use stored-procedures, those should
beconverted / rewritten as well.. 
>
> A bit of a strange question as this is basic datbase knowledge.... ??/ Esp. if you're working at KPN.
> --
> Open Systems Development B.V.
> Peter M. Groen
> Managing Director
> Rooseveltstraat 18-P
> 2321 BM Leiden
> +31 6 12 08 95 62
> email : peter@osdev.nl
> skype : peter_m_groen
>
> On Thu, 2019-12-05 at 12:22 +0000, soumik.bhattacharjee@kpn.com wrote:
> Hi Experts,
>
> Few more details as discussed with application team.
>
> In parallel processing Application will create multiple threads towards our PG database to retrieve/ update data.
>
>
>     • Application will send multiple parallel requests to DB on same table to SELECT data.
>     • Application will send multiple parallel requests to DB on same table to UPDATE data
>     • Application will send multiple parallel requests to DB on same table to INSERT data
>
>
>
> Thanks..
>
> From: Bhattacharjee, Soumik
> Sent: donderdag 5 december 2019 10:48
> To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; 'pgsql-admin@postgresql.org'
<pgsql-admin@postgresql.org>
> Subject: RE: Postgres and Java Microservices Multithreading
>
> Hi Experts,
>
> Please let me know if you have some use cases or documentations around this.
>
> Any response will help me a lot in this context.
>
> Thanks in advance.
>
>
> From: Bhattacharjee, Soumik
> Sent: woensdag 4 december 2019 14:34
> To: 'pgsql-admin@lists.postgresql.org' <pgsql-admin@lists.postgresql.org>; pgsql-admin@postgresql.org
> Subject: Postgres and Java Microservices Multithreading
>
> Hi Experts,
>
> To set the context we are operating in Oracle 11g R2 and our applications are deployed in private cloud and all 15 +
Javamicro services are multithreaded. 
>
> And we are doing database migration from Oracle 11gR2 to Postgres 12.
>
> So if anyone can share your experience or share some documentations/use cases if  we can maintain the same
configurationsfor Java micro services with multithreading as we are using in Oracle and same works in Postgres too? –
(Wejust plan to switch the data source from Oracle to Postgres- will that work? ) 
>
>
> Thanks..




Postgres and Java Microservices Multithreading

From
Scott Ribe
Date:
> On Dec 5, 2019, at 6:33 AM, <soumik.bhattacharjee@kpn.com> <soumik.bhattacharjee@kpn.com> wrote:
>
> Dear Sender,
>
> I am not checking mails on this id, please send mail to my office outlook mail id - SB00567728@TechMahindra.com
>
> Thanks..

LOL, IMO not worth trying to help this guy...






Re: Postgres and Java Microservices Multithreading

From
Tim Cross
Date:
soumik.bhattacharjee@kpn.com writes:

> Thanks Peter for your response, appreciate much.
>
>
>
> But I think the applications wont behave the same way as with Oracle.(We have 15+ Microservices running in
> Oracle with parallel processing)
>
>
>
> Below I just checked and testing in Test Env.
>
>
>
> https://www.postgresql.org/docs/12/parallel-query.html
>
> https://dzone.com/articles/postgresql-connection-pooling-part-1-pros-amp-cons
>
>
>
>
>
> If anyone have some use cases/real time project executions  will be really helpful.
>
>
>

Oracle and Postgres are very different DBMS. While the functionality is
basically equivalent with respect to CRUD operations, the underlying
architecture is very different. This means how query plans are derived,
how indexes, locks etc work are very different and will need different
strategies to optimise performance. You won't just be able to create the
DB schemas in postgres, point your Java microservices to PG and expect
everything to perform in the same way. A lot more effort will be
required in order to get a reliable level of performance.

With regard to your questions concerning parallelism of the java
micro services and the links you posted, I wonder if your confused
regarding how/where you believe this parallel processing is performed.

Assuming (as Peter stated) your Java microservices are separate Java
software (i.e. not Java functions embeded in your 11g db), then what
your dealing with is concurrent connections to your database to perform
CRUD operations. This is distinct to parallel execution of the actual
SQL statements within the database. Connection pooling will likely be a
critical component, especially if the SQL statements are small/simple,
but with a high volume. The overhead of establishing a connection can
easily be as much or more than the actual query in many micro service
type applications.

Likewise, the extent to which your SQL statements are able to take
advantage of parallel processing within the database are likely to be
less relevant compared to correctly structuring transactions
(commits/rollbacks), contention and locking in the database tables.
This in turn depends a lot on the type of application and relationship between
frequency and complexity of queries, updates and inserts.

Even if someone can provide the use cases or other examples, they are
unlikely to be very relevant. Too much depends on the specifics of your
application, your schema design (tables, data types, indexes, number of
columns, table sizes etc), the processing profile and required
performance metrics and how the DB is tuned.

The good news is I suspect PG will be able to satisfy your
requirements. However, the bad news is it sounds like the migration
effort has been woefully under estimated. Based on your questions, I
would also suggest you need to get someone on your team experienced with
PG.

I spent 15+ years working with Oracle before moving to working with
Postgres and after 2 years, I'm still learning every day. The databases
I work with are large (appro 8Tb) and on a slow day we process 1.5
billion updates and inserts and have a number of REST and GrapQL API's
which process large numbers of queries for a number of applications
requiring real-time data. Very little of my Oracle knowledge has been
relevant to working with PG.

Tim

--
Tim Cross



RE: Postgres and Java Microservices Multithreading

From
Date:
Thanks for your response Scott.

It was really valuable, this OOO message was meant for other projects :-) apologies for the same.

Thanks..


-----Original Message-----
From: Scott Ribe <scott_ribe@elevated-dev.com>
Sent: donderdag 5 december 2019 14:47
To: pgsql-admin@lists.postgresql.org
Subject: Postgres and Java Microservices Multithreading

> On Dec 5, 2019, at 6:33 AM, <soumik.bhattacharjee@kpn.com> <soumik.bhattacharjee@kpn.com> wrote:
>
> Dear Sender,
>
> I am not checking mails on this id, please send mail to my office outlook mail id - SB00567728@TechMahindra.com
>
> Thanks..

LOL, IMO not worth trying to help this guy...








RE: Postgres and Java Microservices Multithreading

From
Date:
Thanks Tim, your response covered all :-)



-----Original Message-----
From: Tim Cross <theophilusx@gmail.com>
Sent: donderdag 5 december 2019 15:17
To: pgsql-admin@lists.postgresql.org
Cc: peter@osdev.nl; pgsql-admin@postgresql.org
Subject: Re: Postgres and Java Microservices Multithreading


soumik.bhattacharjee@kpn.com writes:

> Thanks Peter for your response, appreciate much.
>
>
>
> But I think the applications wont behave the same way as with
> Oracle.(We have 15+ Microservices running in Oracle with parallel
> processing)
>
>
>
> Below I just checked and testing in Test Env.
>
>
>
> https://www.postgresql.org/docs/12/parallel-query.html
>
> https://dzone.com/articles/postgresql-connection-pooling-part-1-pros-a
> mp-cons
>
>
>
>
>
> If anyone have some use cases/real time project executions  will be really helpful.
>
>
>

Oracle and Postgres are very different DBMS. While the functionality is basically equivalent with respect to CRUD
operations,the underlying architecture is very different. This means how query plans are derived, how indexes, locks
etcwork are very different and will need different strategies to optimise performance. You won't just be able to create
theDB schemas in postgres, point your Java microservices to PG and expect everything to perform in the same way. A lot
moreeffort will be required in order to get a reliable level of performance. 

With regard to your questions concerning parallelism of the java micro services and the links you posted, I wonder if
yourconfused regarding how/where you believe this parallel processing is performed. 

Assuming (as Peter stated) your Java microservices are separate Java software (i.e. not Java functions embeded in your
11gdb), then what your dealing with is concurrent connections to your database to perform CRUD operations. This is
distinctto parallel execution of the actual SQL statements within the database. Connection pooling will likely be a
criticalcomponent, especially if the SQL statements are small/simple, but with a high volume. The overhead of
establishinga connection can easily be as much or more than the actual query in many micro service type applications. 

Likewise, the extent to which your SQL statements are able to take advantage of parallel processing within the database
arelikely to be less relevant compared to correctly structuring transactions (commits/rollbacks), contention and
lockingin the database tables. 
This in turn depends a lot on the type of application and relationship between frequency and complexity of queries,
updatesand inserts. 

Even if someone can provide the use cases or other examples, they are unlikely to be very relevant. Too much depends on
thespecifics of your application, your schema design (tables, data types, indexes, number of columns, table sizes etc),
theprocessing profile and required performance metrics and how the DB is tuned. 

The good news is I suspect PG will be able to satisfy your requirements. However, the bad news is it sounds like the
migrationeffort has been woefully under estimated. Based on your questions, I would also suggest you need to get
someoneon your team experienced with PG. 

I spent 15+ years working with Oracle before moving to working with Postgres and after 2 years, I'm still learning
everyday. The databases I work with are large (appro 8Tb) and on a slow day we process 1.5 billion updates and inserts
andhave a number of REST and GrapQL API's which process large numbers of queries for a number of applications requiring
real-timedata. Very little of my Oracle knowledge has been relevant to working with PG. 

Tim

--
Tim Cross





Re: Postgres and Java Microservices Multithreading

From
"Peter M. Groen"
Date:
Yep.. Figured... Techmahindra is selling "expertise" to companies like
KPN while their questions are on beginners level.... 
-- 
Open Systems Development B.V.
Peter M. Groen
Managing Director
Rooseveltstraat 18-P
2321 BM  Leiden
+31 6 12 08 95 62
email : peter@osdev.nl
skype : peter_m_groen

On Thu, 2019-12-05 at 06:47 -0700, Scott Ribe wrote:
> > On Dec 5, 2019, at 6:33 AM, <soumik.bhattacharjee@kpn.com> <
> > soumik.bhattacharjee@kpn.com> wrote:
> > 
> > Dear Sender,
> >  
> > I am not checking mails on this id, please send mail to my office
> > outlook mail id - SB00567728@TechMahindra.com
> >  
> > Thanks..
> 
> LOL, IMO not worth trying to help this guy...
> 
> 
> 
> 
> 
> 




Re: Postgres and Java Microservices Multithreading

From
Scott Ribe
Date:
I apologize for the tone of my response.

I just went through having someone email me directly for tech support, and to get my response through was expected to
gothrough one of those "prove you're a human" things. 

So I was in a bad mood about emails being bounced, and didn't consider the obvious option that you'd be reading the
listfor responses. 

--
Scott Ribe
scott_ribe@elevated-dev.com
https://www.linkedin.com/in/scottribe/



> On Dec 5, 2019, at 7:26 AM, <soumik.bhattacharjee@kpn.com> <soumik.bhattacharjee@kpn.com> wrote:
>
> It was really valuable, this OOO message was meant for other projects :-) apologies for the same.




RE: Postgres and Java Microservices Multithreading

From
Date:
No issues Scott.

Thanks...



-----Original Message-----
From: Scott Ribe <scott_ribe@elevated-dev.com>
Sent: donderdag 5 december 2019 17:16
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: Postgres and Java Microservices Multithreading

I apologize for the tone of my response.

I just went through having someone email me directly for tech support, and to get my response through was expected to
gothrough one of those "prove you're a human" things. 

So I was in a bad mood about emails being bounced, and didn't consider the obvious option that you'd be reading the
listfor responses. 

--
Scott Ribe
scott_ribe@elevated-dev.com
https://www.linkedin.com/in/scottribe/



> On Dec 5, 2019, at 7:26 AM, <soumik.bhattacharjee@kpn.com> <soumik.bhattacharjee@kpn.com> wrote:
>
> It was really valuable, this OOO message was meant for other projects :-) apologies for the same.