473,769 Members | 4,202 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database strategy in a multithreaded app.

Hello,

I am writing a server that will be inserting/reading/updating the
database on multiple threads. I understand that you can't have more
than 1 reader open on a database connection. Are there any other
limitations? Like can I have more than one command object inserting on
the same connection? Any other pitfalls, I should look out for?

Thanks.
Nov 16 '05 #1
6 1776
Frank Rizzo <no****@nospam. com> wrote:
I am writing a server that will be inserting/reading/updating the
database on multiple threads. I understand that you can't have more
than 1 reader open on a database connection. Are there any other
limitations? Like can I have more than one command object inserting on
the same connection? Any other pitfalls, I should look out for?


Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Frank,

I am curious what is your goal with this.

The client is accessing a single thread of updating.
It can not read in that time inside one table because it does not know the
concurrency situation and with more tables it has to handle relations.

The connection is accessing over the network or over internet. However it is
one line, you cannot sinful optimize it by using more connections when it
would be to slow what is the normal reason for multithreading here. (Just
give more priority on that line when it is dealt with others)

The database is accessing at full speed the given commands from the clients
one by one and needs as well concurrency synchronization . (However even
without that and with completly unrelated datatables can it only handle one
thing at time)

I am really interested what you want to achieve and than how you would
handle your dependencies.

Cor
Nov 16 '05 #3
Jon Skeet [C# MVP] wrote:
Frank Rizzo <no****@nospam. com> wrote:
I am writing a server that will be inserting/reading/updating the
database on multiple threads. I understand that you can't have more
than 1 reader open on a database connection. Are there any other
limitations ? Like can I have more than one command object inserting on
the same connection? Any other pitfalls, I should look out for?

Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.


Would the application not be slowed down by constant opening/reopening
of the connection?

Nov 16 '05 #4
Cor Ligthert wrote:
Frank,

I am curious what is your goal with this.

The client is accessing a single thread of updating.
It can not read in that time inside one table because it does not know the
concurrency situation and with more tables it has to handle relations.
That's not true, depending on the locking mechanism you can select and
insert at the same time. In my database design, there are very little
concurrency issues. In other words, the clients access a different set
of data - never the same.

The connection is accessing over the network or over internet. However it is
one line, you cannot sinful optimize it by using more connections when it
would be to slow what is the normal reason for multithreading here. (Just
give more priority on that line when it is dealt with others)
Yes, you can, because the bandwidth needed for the commands to the
database is very low. The work is mostly done at either the client
level or the database level.
The database is accessing at full speed the given commands from the clients
one by one and needs as well concurrency synchronization . (However even
without that and with completly unrelated datatables can it only handle one
thing at time).
That's true and that's ok. I can optimize at the database level by
storing all indexes on a different drive, for instance. This way
physical I/O can work in parallel (sometimes). And, of course, you can
always throw more money at the machine.
I am really interested what you want to achieve and than how you would
handle your dependencies.


I am looking for robustness first, speed second. Mostly because you can
buy speed. You can't buy robustness.
Nov 16 '05 #5
Frank Rizzo <no**@none.co m> wrote:
Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.


Would the application not be slowed down by constant opening/reopening
of the connection?


No - it doesn't close the physical connection, it just returns it to
the pool.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6
Jon Skeet [C# MVP] wrote:
Frank Rizzo <no**@none.co m> wrote:
Each operation should usually open a connection, do its stuff, and then
close the connection. Let connection pool handling take care of the
rest for you.


Would the application not be slowed down by constant opening/reopening
of the connection?

No - it doesn't close the physical connection, it just returns it to
the pool.

Thank you very much.
Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2430
by: Eric S. Johansson | last post by:
I have an application where I need a very simple database, effectively a very large dictionary. The very large dictionary must be accessed from multiple processes simultaneously. I need to be able to lock records within the very large dictionary when records are written to. Estimated number of records will be in the ballpark of 50,000 to 100,000 in his early phase and 10 times that in the future. Each record will run about 100 to 150...
1
3759
by: peter wang | last post by:
Hi, Could anyone tell me the backup strategy for a 1000GB database? Thank you! Peter Wang *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
2
6641
by: pradyumna | last post by:
In Project settins - C/C++ - Code Generation, what is the difference between the option "Multithreaded" and "Multithreaded DLL". I understand that on selecting multithreaded option, single and multithreaded applications can both use that dll, but what about multithreaded DLL option. Thanks
19
2758
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested in understanding as much as I can about how I can make this go as fast as possible on a linux system. I haven't run such a large database before. The nature of the database is such that
2
1684
by: Alan Kemp | last post by:
Hi, I have a problem that is half python, half design. I have a multithreaded network server working, each client request spawns a new thread which deals with that client for as long as it is connected (think ftp style rather than http style connections here). Each thread gets passed a reference to the main server to access things like the list of connected clients, global data, etc. Now I want to add a database to store usernames...
0
1250
by: Takpol | last post by:
Greetings Group Members, I am going to implement a strategy for archiving and restoring old filegroups. Part of my data has been stored in date partitioned files and filegroups. So the archive is going to backup older than six months filegroups into the tape and removes them from the production database. The restore strategy is going to work as this: user would be able to ask for restoring old filegroups. Every time there is a restore...
6
3479
by: Stephen Carson | last post by:
I'm trying to build a Web Service that will kick off threads as logging requests come in. These threads will then log to the database. I have been able to make a simple Web Service. I have been able to get a simple multi-threaded example working. I have been used the SqlDataAdapter and DataSet classes extensively to access databases in a deployed Windows Service. But I'm getting confused how to put the pieces together. For example, I...
3
10297
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database I use System.Data.Common.DBConnection and .DBCommand. How can I keep aware from connection losses (network not availeable, db-server not available...)? Are there any strategies to detect this broken connections, and how can I
2
1852
by: Steve | last post by:
I have been asked to convert an Access2002 database to Access2007. The database is used to manage a medium sized company. The company contact said that the existing database was put on a new computer with Access2007 installed and parts of the database did not work. There are about 75 tables, 40 queries, 90 forms and 35 reports. My initial planned strategy is to keep a list at my right hand of all the queries then open each form one by one....
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.