-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Performance drop on multi threading environment
PostPosted: Sat Jan 29, 2011 11:06 pm 
Newbie

Joined: Sat Jan 29, 2011 11:30 am
Posts: 1
I am developing a multi-threading Socket game server for my flash games, I use nhibernate as my project ORM, I have run a stress test for performance with around 100 user it was fast each thread request took less then 1 second to execute and after 150 user it increase to around 2 - 3 second and after 200 user 5 - 12 second and once it hit more then 300 user the request time was around 15 - 30 second, I have run through several testing at all my code that might have cause this problem, it end up that nhibernate transaction cause the delay, once I have remove the transaction code the problem went off it can handle around 500 user with a delay around 1 second or less, I am using SQLServer as database , this is code that cause the problem can someone help take a look if I have done any mistake here thank thank thank a lot . . . :


using (var transaction = Session.SetBatchSize(30).BeginTransaction()) {

try{

Session.CreateQuery("update user_master i set i.balance = i.balance + :win_lose_amount where user_id = :user_id and i.balance + :win_lose_amount >= 0").SetDecimal("win_lose_amount", win_lose_amount).SetInt32("user_id", user_id).ExecuteUpdate();

Session.CreateQuery("update games_win_lose i set games_win = games_win + :games_win,games_lose = games_lose + :games_lose where i.game_id = :game_id").SetDecimal("games_win", games_win).SetDecimal("games_lose", games_lose).SetInt32("game_id", game_id).ExecuteUpdate();

shotter_game_log _shotter_game_log = new shotter_game_log();
_shotter_game_log.game_id = game_id;
_shotter_game_log.symbol_id_1 = 1;
_shotter_game_log.symbol_id_2 = 2;
_shotter_game_log.symbol_id_3 = 3;
_shotter_game_log.symbol_id_4 = 4;
_shotter_game_log.symbol_id_5 = 5;
_shotter_game_log.symbol_id_6 = 6;
_shotter_game_log.symbol_id_7 = 7;
_shotter_game_log.symbol_id_8 = 8;
_shotter_game_log.symbol_id_9 = 9;
_shotter_game_log.symbol_id_10 = 10;
_shotter_game_log.bonus_win = 0;
_shotter_game_log.created_date = DateTime.Now;
_shotter_game_log.created_by = user_id;

Session.Save(_shotter_game_log);

for (int i = 1; i <= location_hit_count; i++)
{
shotter_point_log _shotter_point_log = new shotter_point_log();
_shotter_point_log.shotter_game_log = _shotter_game_log;
_shotter_point_log.hit_point = point[i];
_shotter_point_log.hit_location = location_id[i];
Session.Save(_shotter_point_log);
}

transaction.Commit();
transaction.Dispose();
}
catch (Exception EX)
{
if (transaction != null)
{
try
{
transaction.Rollback();
}
catch (HibernateException HE)
{
Logger.write(HE);
}
}
}

}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.