An sdf file that I produce doesn't get accepted by a converter - sdf

I made a program that converts csv files into sdf files. Those files were supposed to go in another converter that turns them into something called a "Nist MS Library". The problem is that my file doesn't get accepted by the converter for "No spectra have been converted" and I don't understand why.
The files seem identical to me and I think I'm missing something about the specific file extension.
I'm really sorry if this doesn't belong here, I will delete the post if this is the case, but I really do not know where to ask.
I tried to make the "mass spectral peaks" integer, floats, delete them and put some values that I knew for sure that were accepted by the Nist converter, but nothing seems to work.
I will put 2 molecules, the first one is mine, the one that doesn't get accepted, the other one is the one that is fine for the program.
Coumarin
No Structure
0 0 0 0 0 0 0 0 0 0 0
> <NAME>
Coumarin
> <INCHIKEY>
> <FORMULA>
> <MW>
> <CASNO>
91645
> <ID>
2
> <COMMENT>
SAFC Cat. n. W526509\nColumn: SLB-5ms part#28471-U; Supelcowax-10 part#24079; Equity-1 part#28046-U;\nwww.sigmaaldrich.com |RI:1438|
> <SYNONYMS>
Coumarin
> <NUM PEAKS>
140
> <MASS SPECTRAL PEAKS>
39 1
39 233
40 38
40 0
40 0
41 0
41 1
41 5
42 2
42 2
43 35
43 0
43 12
44 26
45 20
45 67
46 7
46 4
46 2
46 1
47 0
48 4
49 32
49 3
50 5
50 166
51 183
52 20
53 35
54 7
55 1
56 0
58 0
59 2
59 23
60 6
60 11
61 89
62 213
63 503
64 164
64 13
65 15
65 7
66 9
68 4
71 0
71 1
72 2
73 1
73 19
74 0
74 32
75 39
76 14
77 11
77 1
78 0
78 0
79 0
79 9
79 0
80 2
80 1
81 0
81 0
81 1
82 0
82 0
83 0
83 0
84 6
84 0
85 17
86 2
86 2
87 28
88 7
89 523
90 581
91 25
91 48
92 40
92 36
93 4
93 5
94 1
94 0
97 2
98 6
98 0
99 2
99 0
100 0
100 1
101 5
102 3
103 0
103 0
103 0
104 0
105 0
105 0
106 0
106 0
106 0
107 0
108 0
109 0
110 0
110 0
111 0
111 0
112 0
112 0
113 0
116 0
117 6
117 0
118 1000
119 94
120 34
120 10
121 4
121 0
122 0
122 0
131 0
135 0
145 1
146 0
146 547
147 58
148 5
183 0
246 0
334 0
351 0
359 0
382 0
> <RI value>
1430.1
$$$$
ETHYL HYDROSULFIDE
(C) 2015 John Wiley & Sons, Inc.
CAS rn = 75081, Library ID = 1
3 2 0 0 0 0 0 0 0 0999 V2000
0.0000 0.2061 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7146 -0.2061 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0
-0.7146 -0.2061 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
M END
> <NAME>
Ethyl hydrosulfide
> <SYNONYMS>
Ethanethiol
$:28DNJIEGIFACGWOD-UHFFFAOYSA-N
$:29n=703/0/1 p=620/0/1
> <FORMULA>
C2H6S
> <MW>
62
> <CASNO>
75081
> <ID>
1
> <COMMENT>
WileyID="LM_FFNSC3_1" RI1="703 (SLB-5MS (Hydro))" RI2="392 (SLB-5MS (FAMEs))" RI3="620 (Supelcowax-10 (FAMEs)" RI4="568 (Supelcowax-10 (FAEEs)" Contributor="Prof. L. Mondello (Chromaleont s.r.l./Univ. Messina, Italy)"
> <NUM PEAKS>
21
> <MASS SPECTRAL PEAKS>
44 20
45 235
46 147
47 727
48 20
49 32
50 2
51 2
52 2
53 2
54 2
55 2
56 16
57 84
58 115
59 84
60 16
61 155
62 999
63 36
64 44
$$$$

Related

Filter rows in mysql

I'm trying to solve a MySQL problem without going crazy. Not sure if it is feasible or not.
Data come from a door/light sensor to detect if toilet is occupied. When door is closed or opened, I get the info + light info. If I have info of closed door and light<10, I say that toilet is not occupied, if light>10, toilet is occupied, and if door is open, toilet is not occupied.
Here is an example of my data :
id wc_id door_open light time
138 0 1 64 2018-10-10 12:28:51
139 0 0 58 2018-10-10 12:34:00
140 0 0 54 2018-10-10 12:34:38
141 0 1 68 2018-10-10 12:35:11
142 0 1 3 2018-10-10 12:35:36
143 0 0 60 2018-10-10 12:37:56
144 0 0 60 2018-10-10 12:37:57
145 0 0 57 2018-10-10 12:38:30
146 0 1 65 2018-10-10 12:43:53
147 0 1 3 2018-10-10 12:44:17
148 0 0 63 2018-10-10 13:10:55
149 0 0 59 2018-10-10 13:11:16
150 0 1 71 2018-10-10 13:12:09
151 0 1 4 2018-10-10 13:12:14
152 0 1 1 2018-10-10 13:15:07
153 0 0 62 2018-10-10 13:17:18
154 0 0 58 2018-10-10 13:18:01
155 0 1 68 2018-10-10 13:19:20
156 0 1 3 2018-10-10 13:19:56
157 0 1 42 2018-10-10 13:26:41
158 0 0 63 2018-10-10 13:26:44
159 0 0 58 2018-10-10 13:27:39
160 0 1 71 2018-10-10 13:27:40
161 0 1 3 2018-10-10 13:28:37
The idea is at the end to have only a series of door_open to 0 to 1, it's not possible to have two 0 or two 1 consecutively.
So I need to keep first door_open=0 with light>10 following a door_open=1, and first door_open=1 after door_open=0, whatever light value.
Is it possible with MySQL? I use MariaDB 10.3.9.
Thanks for your ideas.
The output should be like that :
id wc_id door_open light time
139 0 0 58 12:34:00
141 0 1 68 12:35:11
143 0 0 60 12:37:56
146 0 1 65 12:43:53
148 0 0 63 13:10:55
150 0 1 71 13:12:09
153 0 0 62 13:17:18
155 0 1 68 13:19:20
158 0 0 63 13:26:44
160 0 1 71 13:27:40
(I simplified the time, it's not really important here)
Here is a fiddle
This query should do what you want. It uses a MySQL variable to delay the value of door_open by 1 row, and then returns rows where door_open=0 with light>10 following a door_open=1, and first door_open=1 after door_open=0, whatever light value:
SELECT events.*, #door_open := door_open
FROM events
JOIN (SELECT #door_open := 1) do
WHERE #door_open = 0 AND door_open = 1 OR
#door_open = 1 AND door_open = 0 AND light > 10
Output (from your fiddle data):
id toilet_id door_open light time #door_open := door_open
101 0 false 62 2018-10-10T11:39:31Z 0
103 0 true 69 2018-10-10T11:39:34Z 1
104 0 false 62 2018-10-10T11:42:16Z 0
106 0 true 68 2018-10-10T11:45:50Z 1
109 0 false 56 2018-10-10T12:13:11Z 0
Updated SQLFiddle
Here is the potential answer to my problem, after working on Nick solution. I had to reorder my table (after deleting rows) to avoid an order mess.
select es.id,
es.idNext,
es.toilet_id,
es.time,
es.nextTime,
timediff(es.nextTime, es.time) AS duration
from (
SELECT id, toilet_id, time,
#door_open := door_open as door_open,
lead(id, 1) OVER(ORDER BY id) idNext,
lead(time, 1) OVER(ORDER BY id) nextTime
FROM events e
JOIN (SELECT #door_open := 1) do
WHERE #door_open = 0 AND door_open = 1 OR
#door_open = 1 AND door_open = 0 AND light > 20
) es
where
es.door_open=0 and
timediff(es.nextTime, es.time)>5
Next thing is to update the query to use a partition over toilet_id to separate data from each id.

Mysql find common values for all users

We are developing an local shop reccomendation system and in one of our sql queries we had a problem
We want to fetch the companies which all users in same cluster rated , but if any one of the users in the same group doesnt rated the company we wouldnt want to fetch it
SELECT ml_user_clusters.primaryUser,ml_user_clusters.clusterId,ml_ratings.companyId,ml_ratings.rating,ml_user_labels.groupId FROM ml_user_clusters
LEFT JOIN ml_ratings ON ml_ratings.userId = ml_user_clusters.primaryUser
LEFT JOIN ml_company_user_labels ON ml_company_user_labels.companyId = ml_ratings.companyId
LEFT JOIN ml_user_labels ON ml_user_labels.groupId = ml_company_user_labels.labelId
WHERE ml_user_clusters.clusterId = 0
We've started to add a query like in the below but couldnt able to finish it with proper AND clause
And our data is like in the below: So in the result we would like to have only the companies which has groupId=6 because all users in the same cluster(clusterId=0) rated a company with groupId = 6
primaryUser clusterId companyId rating groupId
497 0 135 5 NULL
498 0 135 10 NULL
79 0 135 12 NULL
501 0 135 10 NULL
79 0 85 14 2
79 0 8 4 5
79 0 98 11 5
79 0 3 5 5
497 0 6 7 6
500 0 6 7 6
499 0 29 7 6
497 0 29 7 6
499 0 77 7 6
500 0 29 7 6
498 0 6 7 6
500 0 77 11 6
500 0 130 3 6
498 0 130 3 6
501 0 77 19 6
499 0 6 7 6
79 0 30 1 7
500 0 30 7 7
79 0 48 7 9
79 0 39 1 13
79 0 48 7 13
499 0 6 7 15
497 0 6 7 15
79 0 8 4 15
500 0 6 7 15
79 0 98 11 15
498 0 6 7 15
79 0 3 5 15
79 0 81 7 15
79 0 3 5 17
79 0 82 7 17
79 0 103 7 17
79 0 118 3 17
79 0 63 3 17
501 0 118 7 17
79 0 82 7 19
79 0 118 3 19
79 0 63 3 19
501 0 118 7 19
79 0 39 1 21
79 0 85 14 23
Expected output must be: (Because all unique users in Cluster=0 has rated a company which has GroupID=6 )
primaryUser clusterId companyId rating groupId
497 0 6 7 6
500 0 6 7 6
499 0 29 7 6
497 0 29 7 6
499 0 77 7 6
500 0 29 7 6
498 0 6 7 6
500 0 77 11 6
500 0 130 3 6
498 0 130 3 6
501 0 77 19 6
499 0 6 7 6
Do you have any idea how we can fix that problem?
Something like this should work,you should build a fiddle for better testing.
Explanation: you count distinct users grouped by group id and compare with the total number of distinct users.If the two match it means all users in that respective groupid have voted.
SELECT ml_user_labels.groupId
FROM ml_user_clusters
LEFT JOIN ml_ratings ON ml_ratings.userId = ml_user_clusters.primaryUser
LEFT JOIN ml_company_user_labels ON ml_company_user_labels.companyId = ml_ratings.companyId
LEFT JOIN ml_user_labels ON ml_user_labels.groupId = ml_company_user_labels.labelId
WHERE ml_user_clusters.clusterId = 0
GROUP BY ml_user_labels.groupId
HAVING COUNT(DISTINCT ml_user_clusters.primaryUser) =
(SELECT COUNT(DISTINCT ml_user_clusters.primaryUser)
FROM ml_user_clusters
LEFT JOIN ml_ratings ON ml_ratings.userId = ml_user_clusters.primaryUser
LEFT JOIN ml_company_user_labels ON ml_company_user_labels.companyId = ml_ratings.companyId
LEFT JOIN ml_user_labels ON ml_user_labels.groupId = ml_company_user_labels.labelId
WHERE ml_user_clusters.clusterId = 0)x

Adding SPLINE to DXF makes the file corrupt (content not shown)

I am working on my own DXF writer because I only need certain elements (such as LINE, POLYLINE, POINT an SPLINE).
I started with tfpdxfbridge and the idea was to include SPLINE support too. When I tried to manually add SPLINE to ENTITIES in the *.dxf file, the file is not opened anymore. Example of SPLINE:
SPLINE
5
274
330
1F
100
AcDbEntity
8
0
100
AcDbSpline
210
0.0
220
0.0
230
1.0
70
8
71
3
72
9
73
5
74
0
42
0.0000000001
43
0.0000000001
40
0.0
40
0.0
40
0.0
40
0.0
40
1.0
40
2.0
40
2.0
40
2.0
40
2.0
10
747.2822841342859
20
1453.676625339077
30
0.0
10
1364.898523055965
20
2324.178049512178
30
0.0
10
2830.924436828291
20
1999.364085075557
30
0.0
10
1130.854480067877
20
862.5152127789023
30
0.0
10
2837.42565094653
20
791.0561394394999
30
0.0
0
Does anybody know what the problem might be or how to make the file work again?
Here is the full file generated with tfpdxfbridge (except the SPLINE part, obviously).
0
SECTION
2
HEADER
999
Generator: TFPDxfWriteBridge
999
By jmpessoa#hotmail.com
9
$DIMASZ
40
0.1800
9
$DIMTSZ
40
0
9
$DIMGAP
40
0.0900
9
$DIMEXO
40
0.0625
9
$DIMDLI
40
0.38
9
$DIMDLE
40
0.0
9
$DIMEXE
40
0.1800
9
$DIMTXT
40
0.1800
9
$DIMTXTDIRECTION
70
0
9
$DIMTIH
70
1
9
$DIMTAD
70
0
9
$DIMCLRD
70
256
9
$DIMCLRE
70
256
9
$DIMCLRT
70
256
9
$DIMASO
70
1
9
$DIMASSOC
280
2
9
$DIMSHO
70
0
9
$DIMLUNIT
70
2
9
$DIMDEC
70
4
9
$DIMADEC
70
2
9
$INSBASE
10
0.0
20
0.0
30
0.0
9
$EXTMIN
10
0.0
20
0.0
9
$EXTMAX
10
3200.0
20
3200.0
9
$LINMIN
10
0.0
20
0.0
9
$LINMAX
10
3200.0
20
3200.0
0
ENDSEC
0
SECTION
2
TABLES
0
TABLE
2
LTYPE
70
8
100
AcDbSymbolTable
100
AcDbLTypeTable
0
LTYPE
2
CONTINUOUS
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____________
72
65
73
0
40
0.000
70
0
0
LTYPE
2
HIDDEN
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ __
72
65
73
2
40
0.375
49
0.250
49
-0.125
70
0
0
LTYPE
2
CENTER
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____ _ ____ _
72
65
73
4
40
2.000
49
1.250
49
-0.250
49
0.250
49
-0.250
70
0
0
LTYPE
2
DOT
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
. . . . .
72
65
73
2
40
0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
DASHDOT
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ . __ .
72
65
73
4
40
1.000
49
0.500
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
DIVIDE
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
____ . . ____ . .
72
65
73
6
40
1.250
49
0.500
49
-0.250
49
0.000
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
BORDER
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ . __ __ .
72
65
73
6
40
1.750
49
0.500
49
-0.250
49
0.500
49
-0.250
49
0.000
49
-0.250
70
0
0
LTYPE
2
MJLINE
100
AcDbSymbolTableRecord
100
AcDbLinetypeTableRecord
3
__ __ __
72
65
73
2
40
0.375
49
0.250
49
-0.125
70
0
0
ENDTAB
0
TABLE
2
STYLE
70
2
100
AcDbSymbolTable
100
AcDbStyleTable
0
STYLE
2
DEFAULT
71
0
40
0.00
42
1.00
50
0.00
41
1.00
3
ARIAL.TTF
100
AcDbSymbolTableRecord
100
AcDbTextStyleTableRecord
70
0
0
STYLE
2
ISOCPEUR
71
0
40
0.00
42
1.00
50
0.00
41
1.00
3
isocpeur.ttf
100
AcDbSymbolTableRecord
100
AcDbTextStyleTableRecord
70
0
0
ENDTAB
0
TABLE
2
LAYER
70
9
100
AcDbSymbolTable
100
AcDbLayerTable
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
0
70
0
62
7
6
CONTINUOUS
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
HIDDEN_YELLOW
70
0
62
2
6
HIDDEN
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
CENTER_RED
70
0
62
1
6
CENTER
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DOT_GREEN
70
0
62
3
6
DOT
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DASHDOT_CYAN
70
0
62
4
6
DASHDOT
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
DIVIDE_BLUE
70
0
62
5
6
DIVIDE
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
BORDER_MAGENTA
70
0
62
6
6
BORDER
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
CONTINUOUS_GRAY
70
0
62
8
6
CONTINUOUS
0
LAYER
100
AcDbSymbolTableRecord
100
AcDbLayerTableRecord
2
MYLAYER
70
0
62
5
6
MJLINE
0
ENDTAB
0
TABLE
2
DIMSTYLE
70
2
100
AcDbSymbolTable
100
AcDbDimStyleTable
0
DIMSTYLE
100
AcDbSymbolTableRecord
100
AcDbDimStyleTableRecord
2
GENERIC
70
0
77
0
176
256
177
256
178
256
41
0.18
46
0.00
44
0.18
42
0.06
147
0.09
140
0.18
3
4
5
6
7
40
1.0
43
0.38
45
0.0
47
0.0
48
0.0
141
0.09
142
0.0
143
25.39999
144
1.0
145
0.0
146
1.0
71
0
72
0
73
1
74
1
75
0
76
0
78
0
170
0
171
2
172
0
173
0
174
0
175
0
0
DIMSTYLE
100
AcDbSymbolTableRecord
100
AcDbDimStyleTableRecord
2
CUSTOM
70
0
77
0
176
3
177
3
178
3
41
0.18
46
0.00
44
0.18
42
0.06
147
0.09
140
0.18
3
4
5
6
7
40
1.0
43
0.38
45
0.0
47
0.0
48
0.0
141
0.09
142
0.0
143
25.39999
144
1.0
145
0.0
146
1.0
71
0
72
0
73
1
74
1
75
0
76
0
78
0
170
0
171
2
172
0
173
0
174
0
175
0
0
ENDTAB
0
ENDSEC
0
SECTION
2
BLOCKS
0
ENDSEC
0
SECTION
2
ENTITIES
0
CIRCLE
100
AcDbEntity
8
BORDER_MAGENTA
62
256
6
BYLAYER
39
0.00
100
AcDbCircle
10
6.00
20
4.00
30
0.00
40
1.20
0
ARC
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbCircle
10
10.00
20
6.00
30
0.00
40
1.20
100
AcDbArc
50
10.00
51
80.00
0
POLYLINE
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
100
AcDb2dPolyline
70
0
66
1
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
0.00
20
0.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
0.00
20
3.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
1.50
20
1.50
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
3.00
20
3.00
30
0.0
0
VERTEX
100
AcDbEntity
8
MYLAYER
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
3.00
20
0.00
30
0.0
0
SEQEND
0
POLYLINE
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
100
AcDb2dPolyline
70
1
66
1
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
-1.00
20
-1.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
-1.00
20
4.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
4.00
20
4.00
30
0.0
0
VERTEX
100
AcDbEntity
8
DOT_GREEN
62
256
6
BYLAYER
39
0.00
100
AcDbVertex
100
AcDb2dVertex
10
5.00
20
-3.00
30
0.0
0
SEQEND
0
ENDSEC
0
EOF
When I try to recover your DXF file I get the following:
Unknown header variable $LINMAX ignored on line 116.
Undefined group code 330 for object on line 1018.
Invalid or incomplete DXF input -- drawing discarded.
In your DXF you have:
330
1F
I see that 330 is included when I do my own spline and save as DXF. But, 330 is according to the documents:
Soft-pointer ID/handle to owner dictionary (optional)
This DXF will recover without any errors:
https://pastebin.com/KRpzCd4M
Perhaps you can do a comparison.

Insert php multiple data into mysql

I have 1000+ customers. I require customer report.
Here debit = potato + onion + ginger. Credit is commission.Balance will be updated every time. It will be balance - debit and balance + credit alternatively.
Grocery data report is as: Data is filled through php form with mysql_fetch_array query. Here few customers are as sample. and few data fields.
id cus_id cus_name potato onion ginger debit credit balance
1 12 munna 10 25 28 63 0 37
2 16 anil 24 56 84 164 0 136
3 34 palash 17 47 51 115 0 85
4 45 dimpy 35 64 39 138 0 112
Table grocery before and after entering new data:
id cus_id cus_name potato onion ginger debit credit balance
1 12 munna 10 25 28 63 0 37
2 16 anil 24 56 84 164 0 136
3 34 palash 17 47 51 115 0 85
4 45 dimpy 35 64 39 138 0 112
5 12 munna 0 0 0 0 6 43
6 16 anil 0 0 0 0 16 152
7 34 palash 0 0 0 0 12 97
8 45 dimpy 0 0 0 0 14 126
My problem is :
I am unable to update balance column, cus_name wise and cus_id wise and insert all data into mysql database. Suggest me with mysql query.

Mysql and High CPU IO Wait

I've the following problem. I'm running a MySQL server 5.1.37 on Ubuntu 9.10 x86 on Amazon. For data store I use EBS volume formatted for ext3.
From time to time the following problem occurs. MySQL start processing about queries 10~20 queries and processing of these takes more than 300sec (These SQL are using filesort). During that time no other transaction could be executed.
I've checked CPU Wait and here what is shows:
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
24 9 66 0 0 0| 0 76k| 258k 989k| 0 0 |5970 3014
23 1 75 0 0 1|4096B 28k| 229k 1536k| 0 0 |3249 2308
19 6 74 0 0 0|4096B 316k| 209k 609k| 0 0 |4943 2542
19 17 62 0 0 2|4096B 36k| 230k 718k| 0 0 |5482 2520
21 19 57 2 0 2| 16k 800k| 271k 860k| 0 0 |6549 2923
23 27 44 5 0 1| 480k 40k| 288k 979k| 0 0 |4140 2682
12 0 86 1 0 0| 256k 48k| 237k 771k| 0 0 |3404 2627
22 1 75 0 0 1|8192B 60k| 285k 908k| 0 0 |4009 2786
54 21 19 3 0 2|4096B 3384k| 287k 1556k| 0 0 |3962 2284
49 24 24 1 0 2|4096B 928k| 285k 2795k| 0 0 |3257 2005
61 19 17 2 0 2|8192B 36k| 215k 577k| 0 0 |3246 1922
40 49 8 0 0 3| 0 40k| 312k 905k| 0 0 |3282 1732
56 23 20 1 0 1|4096B 188k| 247k 897k| 0 0 |3102 2238
39 19 27 16 0 0|4096B 77M| 265k 819k| 0 0 |5147 3075
35 35 12 16 0 1|4096B 56M| 259k 1052k| 0 0 |4656 2739
36 27 8 28 0 1|4096B 59M| 259k 1139k| 0 0 |5549 2821
27 13 36 23 0 1|4096B 64M| 251k 1218k| 0 0 |4207 2540
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
26 4 13 57 0 1|4096B 66M| 275k 681k| 0 0 |5205 3291
22 6 27 43 0 1|4096B 52M| 237k 684k| 0 0 |4906 2602
14 3 24 58 0 0|4096B 46M| 278k 1058k| 0 0 |6448 3687
19 3 34 43 0 2| 32k 51M| 233k 685k| 0 0 |5006 2652
27 3 9 61 0 1|4096B 51M| 294k 800k| 0 0 |4428 2384
17 3 30 50 0 1|4096B 42M| 243k 699k| 0 0 |5334 2830
40 18 0 42 0 0| 0 89M| 247k 840k| 0 0 |4698 2977
31 18 11 39 0 2|4096B 42M| 238k 1269k| 0 0 |4270 2474
17 3 13 66 0 0|4096B 49M| 260k 773k| 0 0 |5153 3100
21 2 14 62 0 1|8192B 46M| 269k 948k| 0 0 |6762 3581
24 2 35 39 0 0|4096B 39M| 256k 777k| 0 0 |5313 2761
15 2 10 72 0 1|4096B 49M| 237k 797k| 0 0 |5312 3018
19 4 22 55 0 0|8192B 47M| 307k 1034k| 0 0 |5508 3278
41 3 15 40 0 1|8192B 47M| 293k 727k| 0 0 |5630 3303
16 2 26 54 0 1|4096B 56M| 282k 1750k| 0 0 |5016 2781
17 3 12 67 0 2|8192B 43M| 238k 824k| 0 0 |5751 3147
14 11 50 24 0 1|4096B 39M| 247k 1105k| 0 0 |4454 2389
41 3 20 35 0 1| 0 58M| 152k 481k| 0 0 |4009 2958
52 2 4 41 0 1|4096B 59M| 211k 621k| 0 0 |5449 2846
31 2 0 66 0 1| 0 52M| 255k 1476k| 0 0 |5167 2693
36 2 24 36 0 2| 12k 49M| 311k 888k| 0 0 |4537 2563
47 7 2 43 0 2|4096B 50M| 231k 750k| 0 0 |4083 2165
40 4 6 50 0 0|4096B 86M| 211k 819k| 0 0 |4768 2875
29 5 2 65 0 0| 0 79M| 180k 580k| 0 0 |4271 4461
40 3 0 57 0 0|4096B 58M| 238k 1489k| 0 0 |4366 4480
27 8 26 38 0 1|4096B 33M| 301k 984k| 0 0 |4439 2838
11 2 9 78 0 1|4096B 24M| 230k 646k| 0 0 |4894 4504
10 3 14 72 0 0|4096B 21M| 183k 549k| 0 0 |4066 3952
14 3 27 57 0 0| 0 64M| 147k 339k| 0 0 |3479 2860
10 2 19 69 0 0|4096B 51M| 112k 452k| 0 0 |2847 2300
9 4 18 69 0 0|4096B 37M| 131k 443k| 0 0 |2923 2004
4 2 49 45 0 0|4096B 31M| 97k 230k| 0 0 |2163 1545
1 2 73 24 0 0| 0 33M| 49k 130k| 0 0 |1425 824
1 0 71 28 0 0| 0 26M| 36k 86k| 0 0 |1426 910
0 0 55 45 0 0| 0 32M| 32k 148k| 0 0 |1334 695
4 0 64 32 0 0| 0 39M| 14k 39k| 0 0 |1262 406
0 2 38 60 0 0| 0 44M| 13k 44k| 0 0 |1136 382
1 1 82 16 0 0| 0 47M| 25k 70k| 0 0 |1228 584
1 3 69 27 0 0|4096B 46M| 23k 60k| 0 0 |1576 599
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
3 1 70 27 0 0|4096B 43M| 22k 54k| 0 0 |1065 574
1 1 33 65 0 0| 0 46M|6124B 17k| 0 0 |1190 345
1 1 49 50 0 0| 0 47M| 11k 22k| 0 0 |1258 444
2 11 23 64 0 0| 56k 58M|9749B 47k| 0 0 |1143 379
1 1 64 34 0 0| 0 51M| 198B 5914B| 0 0 |1048 234
0 1 63 36 0 0| 0 58M| 662B 1278B| 0 0 | 976 454
1 0 81 18 0 0| 0 50M| 426B 6022B| 0 0 |1304 600
0 1 70 29 0 0| 0 43M| 132B 1868B| 0 0 |1150 210
1 1 79 19 0 0| 0 51M| 198B 5914B| 0 0 | 986 246
1 2 30 66 0 0| 0 54M| 246B 420B| 0 0 |1150 288
1 0 49 50 0 0| 0 55M| 659B 6752B| 0 0 |1038 280
1 2 37 60 0 0| 0 47M| 66B 354B| 0 0 |1191 227
0 0 80 19 0 0| 0 43M| 561B 6044B| 0 0 |1129 256
5 13 44 38 0 0| 0 49M|1558B 19k| 0 0 |1225 243
3 6 48 42 0 0| 0 52M| 705B 6022B| 0 0 | 948 327
What could cause such a behavior? Are there any techniques to avoid this?
You're showing a high amount of IO_WAIT status on the CPU (65%). It's possible that you're just pulling too much out of the disks. Try running iostat and seeing what the disk activity is like (namely transactions per second).
However, you mention 10 to 20 queries. Are these queries doing any writing at all? Are they using a transaction? If the answer to either is yes, then you're locking because of the transaction lock in MySQL. If that's the case, your problem is that you need to either figure a way to remove the transaction, or make the queries much more efficient.
A good test would be to create another database on the server. Then run your queries and try to query against the different database. If it works, it's due to transaction locks. If it doesn't, it's likely the disk or some other leak from the VM...
The biggest suspect here is the performance of the EBS volumes, the CPUs may be waiting for I/Os to complete. The next question is what is causing the I/O requests.
This question might be better answered on ServerFault.
http://www.mysqlperformanceblog.com/2011/02/21/death-match-ebs-versus-ssd-price-performance-and-qos/
The IO performance of EBS is poor (I recently benchmarked EBS on a Small instance as being half as fast as my laptop's hard drive). However, you can improve it significantly by striping multiple EBS volumes into a software RAID configuration.
http://alestic.com/2009/06/ec2-ebs-raid
EBS comes with lot of its own limitations, if you are running your instance in the US Region, its better you switch to optimized EBS to make the IO faster. Even I was managing a self managed Mysql but later switched to RDS, which gives a lot better performance then EBS.