Hi,
I have a project using pyramid + ZopeTransactionExtension + SQLAlchemy +
MSSql.
The problem is that when I call *foo_avarage_one_month* once (using curl)
it took about 5 second to response, but when I call it with 2 session
concurrently, it took about 9 second to response!
I run my project on two process and my response time was about 5 second.
What should I do if I want *foo_avarage_one_month *response in 5 second for
any concurrent session?
file: foo_biz.py
from pyramid_rpc.jsonrpc import jsonrpc_method
*class FooBiz:*
@jsonrpc_method(method='foo_avg', endpoint='api')
* def foo_avarage_one_month(self):** foo_keys = [1..500]*
* result = list()*
* for k in **foo_keys: *
* result.append(calc_avg(self.*foo_repo.*find_foo_date_range(k,
*to_day + relativedelta(months=-1)*)))*
* return result*
file: foo_repo.py
*class FooRepo: def find_foo_date_range(self, _key: int, interval_dates:
Tuple) -> List[DailyFoo]: db_session = get_session() query =
db_session().query(DailyFoo)*
* query = query.filter_by(_key=_key) query =
query.filter(DailyFoo.volume > 0) query = query.with_hint(DailyFoo,
'with (nolock)') query = query.filter(DailyFoo.day_key <=
interval_dates[1]) query = query.filter(DailyFoo.day_key >=
interval_dates[0]) query = query.order_by(DailyFoo.day_key.desc())
return query.all()*
file: alchemy_config.py
*_db_session = Nonemetadata = Nonedef get_session(): return _db_sessiondef
create_db_session(settings): global _db_session, metadata engine =
engine_from_config(settings, 'engine.sqlalchemy.') _db_session =
scoped_session(sessionmaker(bind=engine, extension=ZopeTransactionExtension()))
metadata = MetaData(bind=engine)*
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.