I'm curious what everyone's adopted standard is regarding creating
remote connections to access remote databases from VFP.
Specifically, how often do you create/open and close connections in
both a desktop and web environment? Some may use different approaches
for each environment, others may use the same for both.
I can imagine two approaches:
1) Create 1 global shared connection *for each database* you need to
connect @ startup - All forms, business objects, web pages, etc..
look to use this connection. The connection remains open the life
time of the application. Multiple open forms on a desktop app will
still only use the 1 connection, thus with 6 open forms, only 1
connection is used. Each web process will use the same global
connection to process an incoming request.
2) Create all connections as needed and close when done, aka, all
forms, business objects, web pages, etc open their own connections as
needed. The connection is only open as long as the need to pull/push
the data exists. Multiple open forms on a desktop app will each have
1 or more connections, thus with 6 open forms, a minimum of 6
connections per user can be possible. Each web process will create a
new connection to process the incoming request, but since web
processes can only operate 1 at a time, only 1 connection per
database would be open realistically.
Approach 1
Pros:
1) Limits the # of active connections at a given time to absolute minimum
a) Especially important if licensing is tied to # of connections.
b) Beneficial for memory usage on pc & server? (I'm assuming this
is true, but have not tested to be sure).
2) Keeps network traffic down? (I'm assuming this is true, but have
not tested to be sure).
Cons:
1) Possibility that the connection becomes unavailable during it's
lifetime, so code must be written to ensure the connection is still active.
2) Overuse of a single connection could cause performance degradation
to the overall application or to the server? (I'm just guessing, I
haven't tested to see if this is actually true).
Approach 2:
Pros:
1) More open to object oriented approach where everything is self-contained.
2) Connections don't remain open when not in direct use.
Cons:
1) May exceed max # of allowed or licensed connections
2) Keeps more connections open than is necessary
I am personally leaning towards Approach 1 for both web & desktop
apps as it seems to make much more sense based on the pros & cons I
could think of, but wanted to hear what your opinions were since you
may have thought of issues that I am forgetting or have personal
experience which proves one way is better.
Thanks-
Steve
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.