天天看点

对MapGuide/AIMS进行压力测试StressTest并进行性能优化

你按照缺省配置部署AIMS或者MapGuide时也许发现,这个系统的性能并不是很好,并发用户稍微多一点就MapGuide Server就死掉了。这是因为MapGuide的缺省配置只是比较安全的一个设置,能确保在大多数机器配置下能够运行而已,但如果把这个缺省配置应用到正式生产环境中,性能就会出现问题,我们必须根据实际情况对MapGuide Server的配置进行优化。相关设置可以在serverConfig.ini里面调整,这个文件缺省在C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Bin目录下。

那么更改那些参数,改为多少合适呢? 为了更有针对性的对MapGuide中serverConfig.ini中的参数修改来达到性能优化,我们可以先通过压力测试一下,看看那个环节出问题。压力测试有不少工具,比如Grinder,LoadRunner,Microsoft Web Application Stress Tool等等,你可以选用你自己熟悉的工具。

先说一下我的测试环境,我的笔记本:

8G 内存 开始测试时已用内存3.2G,我开了一些常用的程序,包括现在正在用来写博客的LiveWriter。 Windows 7 64位 Autodesk Infrastructure Map Server 2013 64位
对MapGuide/AIMS进行压力测试StressTest并进行性能优化

下面是测试方法:

1. 安装测试环境

Grinder是基于Java编写的,首先你需要配好Java环境,这里不细说,网上一搜一大堆。

2. 修改测试脚本参数

Grinder的MapGuide压力测试脚本修改,由于这段脚本是针对Sheboygan示例数据进行测试的,如果你没有这个示例数据,可以从OSGeo来下载,当然如果你需要测试你自己的数据,那么需要对测脚本进行更改,我这里先对Sheboygon数据来测试。 打开scripts/grinder.properties,更改为: grinder.script = sheboyganNet.py             测试.net版本的AIMS grinder.processes = 10                           10个并发用户  grinder.threads = 1 grinder.runs = 0  execfile('.\scripts\Params_Basic2010.py') execfile('.\scripts\Params_SheboyganCommon.py') #Mapguide Server url PARAM_WebLayout = "Library://Samples/Sheboygan/Layouts/SheboyganAsp.WebLayout" PARAM_MapDefinition = "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition" PARAM_MapName = "Sheboygan" PARAM_InitialLegendLayers = ["Library://Samples/Sheboygan/Layers/Islands.LayerDefinition",     "Library://Samples/Sheboygan/Layers/Hydrography.LayerDefinition",     "Library://Samples/Sheboygan/Layers/CityLimits.LayerDefinition",     "Library://Samples/Sheboygan/Layers/Districts.LayerDefinition",     "Library://Samples/Sheboygan/Layers/Parcels.LayerDefinition"] execfile('.\scripts\Script_BasicNet2010.py')

3 运行测试

如果你是第一次运行Grinder,首先运行一下SetClasspath.bat把Grinder的相关库加入到classpath中去,运行一次就可以了。 双击StartConsole.bat 启动控制台 双击StartAgent.bat启动代理
对MapGuide/AIMS进行压力测试StressTest并进行性能优化

对AIMS 2013的缺省安装设置进行10个并发用户的压力测试,不一会儿在Error.log里就出现了下面的错误,表明不能在创建新的的会话session了。

<2012-08-30T16:00:53>     74620        127.0.0.1    Administrator

Error: Cannot create repository: Session:d20be822-f278-11e1-8000-1cc1de9ea86d_en_MTI3LjAuMC4x0AF20AF10AF0//

StackTrace:

  - MgSiteServiceHandler.ProcessOperation() line 83 file d:\build\ims2013\build_52.8\ent\os\server\src\services\site\SiteServiceHandler.cpp

  - MgOpCreateSession.Execute() line 109 file d:\build\ims2013\build_52.8\ent\os\server\src\services\site\OpCreateSession.cpp

  - MgServerSiteService.CreateSession() line 762 file d:\build\ims2013\build_52.8\ent\os\server\src\services\site\ServerSiteService.cpp

  - MgServerResourceService.CreateRepository() line 491 file d:\build\ims2013\build_52.8\ent\os\server\src\services\resource\ServerResourceService.cpp    

<2012-08-30T16:00:53>     74820        127.0.0.1    Administrator

Error: Cannot create repository: Session:d203d196-f278-11e1-8000-1cc1de9ea86d_en_MTI3LjAuMC4x0AF20AF10AF0//

  - MgServerResourceService.CreateRepository() line 491 file d:\build\ims2013\build_52.8\ent\os\server\src\services\resource\ServerResourceService.cpp   

那么如何优化呢?我进入到serverConfig.ini里面,修改参数配置如下,请注意高亮的部分。

[ResourceServiceProperties]

# *****************************************************************************

# R E S O U R C E  S E R V I C E

#

# Property Name                    Description

# -----------------------------------------------------------------------------

# LibraryRepositoryPath            Path where the Library repository is stored

# LibraryResourceDataFilePath      Path where the Library resource data files

#                                  are stored

# PackagesPath                     Path where the resource packages can be found

# RepositoryCheckpointsTimerInterval Time duration in seconds for when the server

#                                  performs checkpoints for all the repositories

#                                       0 < Value <= 2147483647

# ResourceChangeTimerInterval      Time duration in seconds for when the server

#                                  dispatches resource change notifications

# ResourceDataFileTrashFolderName  Folder where the repository trash files are

#                                  stored

# ResourcePermissionCacheSize      Max # of resources with permission

#                                  information to be cached

#                                       0 <= Value <= 2147483647

# ResourceSchemaFilePath           Path where the resource schema files are

# SessionRepositoriesConfig        Sets whether to use a single file session

#                                  repository or a session repository file per session.

#                                       SingleFile or FilePerSession

# SessionRepositoriesLimit         The total number of active session files allowed.

#                                  This setting only works when FilePerSession

#                                  is used.

# SessionRepositoryPath            Path where the Session repository is stored

# SessionResourceDataFilePath      Path where the Session resource data files

# SiteRepositoryPath               Path where the Site repository is stored

LibraryRepositoryPath = C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Repositories\Library\

LibraryResourceDataFilePath = C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Repositories\Library\DataFiles\

PackagesPath = C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Packages\

RepositoryCheckpointsTimerInterval = 600

ResourceChangeTimerInterval = 5

ResourceDataFileTrashFolderName = Trash

ResourcePermissionCacheSize = 1000

ResourceSchemaFilePath = C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Schema\

SessionRepositoriesConfig = FilePerSession

SessionRepositoriesLimit = 2000

SessionRepositoryPath = C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Repositories\Session\

SessionResourceDataFilePath = C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Repositories\Session\DataFiles\

SiteRepositoryPath = C:\Program Files\Autodesk\Autodesk Infrastructure Map Server 2013\Repositories\Site\

[SiteServiceProperties]

# S I T E  S E R V I C E

# SessionTimeout                   Time duration in seconds for when an idle

#                                  session is expired

#                                       0 < Value <= 86400

# SessionTimerInterval             Time interval in seconds for when the server

#                                  checks for idle sessions

SessionTimeout = 400

SessionTimerInterval = 200

其中SessionRepositoriesLimit的值表示允许创建的活动会话Session的个数,缺省值是200,这个太小了,我把这个值增大为2000. 下面还对SessionTimeout  和 SessionTimerInterval 的值进行了更改,SessionTimeout表示session过期的时间,SessionTimerInterval 表示隔多长时间来检查session是否过期。在session过期时MapGuide Server就会释放掉相应的内存,这里把session过期时间缩短和检查间隔缩短,以便MapGuide Server能及时清理不用的Session。经过这样的设置之后,我上面的错误信息消失了。

下面是100个并发用户的压力测试截图,没有任何错误信息:

对MapGuide/AIMS进行压力测试StressTest并进行性能优化
对MapGuide/AIMS进行压力测试StressTest并进行性能优化
对MapGuide/AIMS进行压力测试StressTest并进行性能优化

CPU及内存使用情况:

对MapGuide/AIMS进行压力测试StressTest并进行性能优化
对MapGuide/AIMS进行压力测试StressTest并进行性能优化

活动session数是和你的可用内存息息相关的,可能话尽量多配内存,并使用64位版本,另外增加配置文件中的允许session数并缩短session时间和过期检查事件以便及时清理掉不用的session。

好了,看到这里,你对MapGuide的性能有信心吗?

邮箱:[email protected] 

转载请保留此信息。

本文转自峻祁连. Moving to Cloud/Mobile博客园博客,原文链接:http://www.cnblogs.com/junqilian/archive/2012/08/31/2664231.html,如需转载请自行联系原作者

继续阅读