I am having some performance trouble in our production server.
1) The principal query takes generally 0.5 secs, but sometimes it takes 20 secs, (then the client goes crazy because it's seems that crashed). The query is over a view and it does not have any eager or lazy object attached, only plain attributes. The query returns 100 paginated records (over 65.000 records)
Why is so variable? How can I improve the query, as the query is working fine most of the times?
2) Generally, the Javamelody stats show that server uses between 5 and 10 connections at same time. But sometimes this goes up to the max (100) and then the server goes busy and unstable.
We are having between 1800 and 2000 sessions working on the app.
This is my config:
Tomcat Server: AWS Linux EC2 Instance t2.medium
MS SQL Server: AWS Windows EC2 Instance c4.large (it has a SQL Server Express and now we are moving to an SQL Server Web Edition to get more powerful [maybe this is the problem?])
JDBC Connection Pooling Configuration:
<bean class="org.apache.commons.dbcp2.BasicDataSource" id="dataSource">
<property name="url" value="jdbc:sqlserver://url..."/>
<property name="username" value="username..."/>
<property name="password" value="password..."/>
<property name="initialSize" value="10"/>
<property name="maxTotal" value="100"/>
<property name="maxIdle" value="50"/>
<property name="minIdle" value="10"/>
</bean>
Should I change connection pooling config? How can I improve these leaks?
Thank you, and sorry for my english.
I confirm that 5 to 10 jdbc connections used at the same time, with queries taking about 0.5s is a lot. That's a clear indication that the database is certainly heavy loaded, even more so when having only 2 vcpu.
Queries taking sometimes 20s, instead of 0.5s, is just when the database has severe difficulties to keep up with the load: they are put waiting in queue.
And used jdbc connections increasing to 100 is when the database just "gives up": imagine 100 queries at the same time, when it already has difficulties to keep up with 5 to 10 queries at the same time.
In this case, sql queries should be optimized or the database server should changed.
Related
We are having a OLAP SSAS cube setup and the Cube Processing is triggered from SQL Server Agent Job (on SQL Server 2014). The SQL Server Agent Job step is as below:
<Batch xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<Parallel MaxParallel="3">
<Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Object>
<DatabaseID>{DatabaseID}</DatabaseID>
<CubeID>{CubeName}</CubeID>
</Object>
<Type>ProcessFull</Type>
<WriteBackTableCreation>UseExisting</WriteBackTableCreation>
</Process>
</Parallel>
</Batch>
This step is supposed to trigger three parallel measure pull call from the SQL Server databases. But what we could see is it is triggering 10 parallel select queries to the Database. There are few other cubes which has similar parallel settings and fire only 3 queries at a time. The issue of 10 calls are happening only in case of this cube and is happening only in one specific environment. Is there any settings at SSAS cube level which overrides the parallel setting set by the SQL Agent Job?
I think the setting you want is: Maximum Number of Connections in the Data Souce.
https://learn.microsoft.com/en-us/analysis-services/multidimensional-models/set-data-source-properties-ssas-multidimensional?view=asallproducts-allversions
Specifies the maximum number of connections allowed by Analysis Services to connect to the data source. If more connections are needed, Analysis Services will wait until a connection becomes available. The default is 10. Constraining the number of connections ensures that the external data source is not overloaded with Analysis Services requests.
The maxParallel attribute for Parallel element controls the number of processing threads.
https://learn.microsoft.com/en-us/analysis-services/xmla/xml-elements-properties/parallel-element-xmla?view=asallproducts-allversions
Indicates the maximum number of threads on which to run commands in parallel. If not specified or set to 0, the instance of Analysis Services determines an optimal number of threads based on the number of processors available on the computer.
We have two separated enviroments with Oracle Database one with version 12.1.0.2(Server1)other 12.2.0.1(Server2). Both DBs are stored in independent machines
The issue is that, for example a query in Server1 takes 3 seconds and in Server2 it takes 6 seconds. This doesn't sound that bad but we access the DB through different services like IBM Cognos so we have to add the time that takes the service to perform its tasks to the total time it takes to execute the query.
The result is that for the same process in Server1 it takes seconds to complete it vs in Server2 it takes some minutes.
Do you have any ideas as to why could this happen?
Thanks
I discovered that since NHibernate 5.0 I can call the following code to delete all records of a table:
session.Query<T>().Delete();
It executes the code on the database without copying it across the network, which should improve performance a lot.
But this query times out.
I get the following error:
Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
I've tried setting the Connection Timeout setting in my connectionstring to 0 and to 3600, but it makes no difference.
My table only has about 200 records. But one column is a base64 encoded pdf, so it is quite big and the query would take a few seconds.
What else can I try?
It sounds like you need to increase the command timeout.
Note that there is a difference between connection timeout and command timeout.
You can set the default command timeout (in seconds) for ADO.NET commands created by NHibernate using the command_timeout NHibernate session configuration property. There are multiple ways to do that depending on what method you use to configure NHibernate. Here are the basics: http://nhibernate.info/doc/nhibernate-reference/session-configuration.html
I use hazelcast 3.8.4 and IMap.
I set in hazelcast.xml
<map name="default">
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<read-backup-data>true</read-backup-data>
and I observe get/s per server in management center.
I think about this situation.
I put key 3, 4. And key 3 owner is server A, key 4 owner is server B.
before I set read-backup-data true, if I get key 3, only server A's get/s is up in management center.
After I set read-backup-data true, I expect not only get/s of server A but also server B will up.
But it didn't.
Why?
thanks in advance.
read-backup-data would only kick in if you try to read the value from server B itself. It does not help to have multiple servers as value sources when using clients. This would mitigate the idea of how Hazelcast distributes not only data but also optimizes request latencies by sending requests from clients directly to the record-owing cluster node, if that makes sense.
I have an old ASP .NET Web Forms application. Code-behind - VB .NET. It has been working for like 10 years. All was fine and worked very fast.
But yesterday I faced next problem: my SQL querys to database began to take much longer time.
I had next code in .aspx file:
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand=" "SOME SELECT DB QUERY (hardcoded)" ">
<!-- I know, that it is bad way to configure select command. But I'm not an author -->
<SelectParameters>
<!-- Parameters -->
</SelectParameters>
</asp:SqlDataSource>
This SQL query take like < 0.1 sec to be processed with every parameter (tested) on server in MS SQL management studio. Thats fine.
But my application started to take timeout error. In SQL server profiler this querys (hardcoded) was taking for > 30 sec's (timeout) (with some parameters It worked for like 14 - 20 sec's. But it is still much more longer, that was for like 2 days ago).
Important: I have solved this issue. I have maked stored procedure in my MS SQL database with this select query.
And changed .aspx code to this one:
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand=" "PROCEDURENAME" " SelectCommandType="StoredProcedure">
<SelectParameters>
<!-- Parameters -->
</SelectParameters>
</asp:SqlDataSource>
And that solved my issue.
Question is: Why has it solved my issue? I can't really understand this. And it's very interesting for me.
Full error code
Maybe your DB connect query might be taking more time to execute, or server is taking more time to execute DB query, You can check the server where DB is hosted.
Check if there are too many application pools running for IIS.
You can also increase CommandTimeout for your connection from the config file.