从TimesTen 7.0.3 开始,有如下三个新的Client/Server配置属性:

MaxConnsPerServer:每个子服务进程所能处理的并发连接个数,缺省为1,范围为1-2047。

ServersPerDSN:每个DSN所预先派生的子服务进程,缺省为1,范围为1-2047

ServerStackSize:为客户端连接提供服务的子服务进程占用的空间大小。32位系统上缺省为128K,64位系统上则为256K。

以前的版本只能是一个客户端连接对应一个服务器端的服务进程。现在服务器端的一个服务进程可以通过设置MaxConnsPerServer,来调整该服务进程所能派生的线程个数,从而通过线程来支持客户端的连接请求。即通过多线程机制来支持更多的并发连接。从而减少了系统的资源开销,提高了性能。但不好的地方是:如果该服务进程死掉了,该服务进程所派生的线程的服务将终止,所有相关的客户端连接将中断。

 下面通过一个试验来演示一下其中的不同之处。

缺省的ttendaemon.options (和sys.odbc.ini处于同一个目录下)配置如下:

[tt703@west-mountain info]$ cat ttendaemon.options
# Commented values are default values
#-supportlog /home/tt703/TimesTen/tt703/info/ttmesg.log
#-maxsupportlogfiles 10
#-maxsupportlogsize 0×100000
#-userlog /home/tt703/TimesTen/tt703/info/tterrors.log
#-maxuserlogfiles 10
#-maxuserlogsize 0×100000
#
-verbose
-showdate
-server 17032
-serverShmIpc
-serverShmSize 128

配置Client/Server模式的DSN,并起三个控制台终端,通过ttisqlCS连接DataStore。

[tt703@west-mountain info]$ ttisqlcs ttclient
[tt703@west-mountain info]$ ttisqlcs ttclient
[tt703@west-mountain info]$ ttisqlcs ttclient

然后通过ttStatus查看连接信息

[tt703@west-mountain ~]$ ttstatus
TimesTen status report as of Tue Aug 12 13:19:31 2008Daemon pid 4261 port 17030 instance tt703
TimesTen server pid 4273 started on port 17032
No TimesTen webserver running
------------------------------------------------------------------------
Data store /home/tt703/datastore/ttserver
There are 9 connections to the data store
Data store is in shared mode
Shared Memory KEY 0x12037898 ID 163842
Type            PID     Context     Connection Name              ConnID
Server          4421    0x0836f6c8  ttclient                          1
    (Client Information: pid: 4416; IPC: TCP/IP;
        Node: west-mountain (127.0.0.1))
Server          4435    0x093046b8  ttclient                          2
    (Client Information: pid: 4430; IPC: TCP/IP;
        Node: west-mountain (127.0.0.1))
Server          4443    0x0898a6b8  ttclient                          3
    (Client Information: pid: 4438; IPC: TCP/IP;
        Node: west-mountain (127.0.0.1))
Subdaemon       4264    0x09707248  Worker                         2042
Subdaemon       4264    0x0978f8a0  Flusher                        2043
Subdaemon       4264    0x097cefd8  Aging                          2045
Subdaemon       4264    0x097fe708  HistGC                         2046
Subdaemon       4264    0x0981de30  Monitor                        2047
Subdaemon       4264    0xb2b00470  Checkpoint                     2044
Replication policy  : Manual
Cache agent policy  : Manual
------------------------------------------------------------------------
Access control enabled.
End of report

可以看到每个客户端的连接对应了一个Server进程,进程号分别为4421,4435,4443。

退出所有的连接并关闭TimesTen Daemon。

修改ttendaemon.options,如下,最后加了一行

[tt703@west-mountain info]$ cat ttendaemon.options
# Commented values are default values
……
-verbose
-showdate
-server 17032
-serverShmIpc
-serverShmSize 128
-maxConnsPerServer 3

重启TimesTen Daemon,再次通过三个控制台 ttisqlcs 连接到DataStore,并通过ttStatus查看

[tt703@west-mountain info]$ ttdaemonadmin -start
[tt703@west-mountain info]$ ttisqlcs ttclient
[tt703@west-mountain info]$ ttisqlcs ttclient
[tt703@west-mountain info]$ ttstatus
......
Data store /home/tt703/datastore/ttserver
There are 9 connections to the data store
Data store is in shared mode
Shared Memory KEY 0x14037898 ID 327682
Type            PID     Context     Connection Name              ConnID
Server          4511    0x0919d780  ttclient                          1
    (Client Information: pid: 4506; IPC: TCP/IP;
        Node: west-mountain (127.0.0.1))
    (Client Information: pid: 4523; IPC: TCP/IP;
        Node: west-mountain (127.0.0.1))
    (Client Information: pid: 4529; IPC: TCP/IP;
        Node: west-mountain (127.0.0.1))
Server          4511    0x091f6b00  ttclient                          2
Server          4511    0x0922d1e8  ttclient                          3
Subdaemon       4474    0x08b72248  Worker                         2042
Subdaemon       4474    0x08bfa818  Flusher                        2043
Subdaemon       4474    0x08c39f50  HistGC                         2046
Subdaemon       4474    0x08c49568  Monitor                        2045
Subdaemon       4474    0xb2a00470  Checkpoint                     2047
Subdaemon       4474    0xb2a0fa88  Aging                          2044
Replication policy  : Manual
Cache agent policy  : Manual

此时,看到服务的进程只有一个,进程号为4511(虽然显示了3行),但派生了三个线程分别服务于客户端的连接。这是因为我们设置了每个服务进程派生三个线程来提供服务。

如果再增加一个客户端的连接,情形会怎么样呢?结果如下:

Server 4511 0×0922d1e8 ttclient 3
Server 4604 0×0914d790 ttclient 4

发现多了一个进程号为4604的服务进程,如果4604派生的三个线程用完了,又将有新的服务进程产生。

留言