RE: Scaling / Number of simultaneous connections

Поиск
Список
Период
Сортировка
От Danny Severns
Тема RE: Scaling / Number of simultaneous connections
Дата
Msg-id 269ff98799e44ecd92fa3cfe88ec84dd@JANDC000-MBN17.ventech.com
обсуждение исходный текст
Список pgsql-novice

This is a difficult question that is hard to give a specific answer, because there are so many variables.  Andreas’ answers was correct given his assumption that 50 possible users are not active at one time.  I think an implied assumption in his answer is that the active users, at any point in time, are not each doing high volume computing requiring high CPU and database usage.

 

You never specifically state it, but I assume from the question that you are referring to a single processor server, and that it is a real server, not a desktop computer being used as a server.  The difference being the type of CPU, Xeon instead of a Pentium Class CPU, high speed disk, instead of SATA disks as used in desktop computers, and high RAM amounts adequate for 20-50 users, not 8 or 16 GB desktop configurations.  If that is the type of server you are talking about, which I’m sure he assumed, then again, I feel Andreas’ answer was correct.

 

Don’t confuse Cores, processes and threads.  For example, most CPUs state they have, for example, 4 cores and 8 threads.  It is my understanding that what the 8 threads means in the context of the Cores, is that each Core gives the illusion of being 2 Cores.  Again, for example, my laptop has an i7-4700, 4 cores, 8 thread, CPU.  If I look at the Task Manager > Resource Monitor > CPU tab, on the right side of the screen listed vertically, I will see 8 activity frames labeled CPU 0 thru CPU 7, i.e. 8 Cores.  This is all from the perspective of hardware.

 

With respect to software, each process starts execution with a single thread.  It will remain a single thread until your program starts a new thread, at which time the process becomes multi-threaded.  Those multiple threads run in parallel within the parent process, and most likely within a single Core.  A single process can have unlimited threads.  I say “most likely” because the Operating System is going to determine whether it will use another Core in which to run your additional threads, and if you run multiple processes with multiple threads, it will decide how to split those across multiple Cores.  At least that is my understanding.

 

A good example of this that you can observe, is if you use Firefox on Windows (and this may be true of other browsers, I just have never looked), open several tabs, then invoke the Task Manager.  On the Process tab you will see a process for each tab.  Then look at the Resource Monitor > CPU tab > Firefox Processes.  You will see each process listed in the first column, and multiple threads for each process listed in the Threads (5th) column.  That means when the user opens another tab, FF fires off another process within which to handle that tab, and further invokes multiple threads within which to handle different activities like screen io, user key/mouse clicks, windows events, OS messages, etc. all running in parallel.

 

If you have a current version of Quickbooks on premise app (as opposed to the cloud version), it provides a good contrast to Firefox.  And you may be able to do the same with another app on your pc.  When you invoke QB, it runs as a single process no matter how many functions or programs you open.  When you look at QB in Task Manager, you will see a single process with many threads, it can several hundred.

 

The point of the above with respect to your question, is that the adequacy of a single CPU server to handle up to 50 users, very much depends on how your Delphi app is written.  If it runs as a single process, single thread, for each user, it most likely will not use more than a single Core because the OS will not be able to split the functionality of the app.  When the app calls Postgres for data io, Postgres will run based on how it is written, which is to run as multiple processes with multiple threads.  Therefore, various Postgres functions may run in parallel across different Cores as the OS deems necessary.  Again, start Postgres and look at it with Task Manager > Resource Monitor, and you will see multiple processes and multiple thread even if your app is not accessing it at the moment.

 

Based on many years of selling Unix/Linux and Windows servers, networks, and developing business apps for the SMB market, i.e. 20-50 users, I would say that if your user count is frequently above 20-25 and they are active users, and the app invokes a lot of db activity, a single server will not be adequate.  What is usually done in that case, is the db is installed on a separate db server, so the app server is free to handle all the user and app activity, and the db server is free to handle only Postges activity.  That configuration should be adequate for a 50-user app no matter how many users are logged in and no matter how many are generating high db activity.  Obviously, there are exceptions, but I am speaking generally, and in the context of most business apps.  My answer also assumes the servers are real servers.

 

HTH

Danny

 

From: Nico Callewaert <app.development1972@gmail.com>
Sent: Thursday, February 07, 2019 11:44 AM
To: pgsql-novice@lists.postgresql.org
Subject: Scaling / Number of simultanous connections

 

Hi,

 

I'm about to start porting a Firebird DB to Postgres. Next thing will be upgrading all customers. Most of our customers have around 30 users or less. We have a few 'bigger' customers that maybe have 50 users or a bit more still. The application is a Delphi application that is in fact a 'fat' client that uses a permanent connection to the DB. I've read that Postgres uses 1 process per user. So that means 30-50 processes at the same time. 

 

I have 2 questions about this

- I guess this situation is not really a heavy workload? Or is it?

- And is it correct that a single process cannot access multiple CPU cores, so things are not multi threaded? I guess MySQL used that argument somewhere, but I'm not sure, forgive me if I'm mistaken.

 

The whole thing boils down to this question: Am I save with 30-50 simultanous users for speed and scaling?

 

Thanks a lot in advance!

Best regards, Nico

В списке pgsql-novice по дате отправления:

Предыдущее
От: Andreas Kretschmer
Дата:
Сообщение: Re: Scaling / Number of simultanous connections
Следующее
От: Lars Gustafsson
Дата:
Сообщение: Legacy app not working with newer PG, is there a quick fix?