Problem Description
When trying to use quotas to do a PI or SI query, my query keeps returning quotas exceeded. The user has 1000 read quota assigned to it and none of it is getting used, but I’m still exceeding the quota.
Admin> show users
~~~~~~~~~~~Users (2025-09-04 17:00:38 UTC)~~~~~~~~~~~~
To see individual users metrics run 'show user
statistics'
User| Roles|~Read~|~Write~
| | Quota| Quota
admin| user-admin|0 |0
test |read,quotarole,sys-admin,write|1000 |0
Number of rows: 2
aql> SELECT * FROM test.demo
Error: (83) AEROSPIKE_QUOTA_EXCEEDED
Admin> show users statistics
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Users Statistics (2025-09-04 17:02:40 UTC)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
User| Node|Connections|~~~~~~~~~~~~~~~~~~Read~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~Write~~~~~~~~~~~~~~
| | | Quota|Usage%| Single| PI/SI| PI/SI| Quota| Single| PI/SI| PI/SI
| | | | | Record| Query| Query| | Record| Query| Query
| | | | | TPS|Limited|Limitless| | TPS|Limited|Limitless
| | | | | | RPS| | | | RPS|
admin|dc2-1:3000| 4.000 |0.000 | --|0.000 |0.000 | 0.000 |0.000 |0.000 |0.000 | 0.000
admin| | 4.000 |0.000 | --|0.000 |0.000 | 0.000 |0.000 |0.000 |0.000 | 0.000
test |dc2-1:3000| --|1.000 K| 0.0 %|0.000 |0.000 | 0.000 |0.000 |0.000 |0.000 | 0.000
test | | --|1.000 K| 0.0 %|0.000 |0.000 | 0.000 |0.000 |0.000 |0.000 | 0.000
Number of rows: 2Explanation
If RPS (recordsPerSecond) is set to 0 on the client side, the PI or SI query would fail with quotas exceeded. RPS must be set to a non-zero value if you would like to use quotas with PI or SI queries.
aql example:
aql> GET SCAN_RECORDS_PER_SECOND
SCAN_RECORDS_PER_SECOND = 0
aql> SET SCAN_RECORDS_PER_SECOND 10
SCAN_RECORDS_PER_SECOND = 10
aql> GET SCAN_RECORDS_PER_SECOND
SCAN_RECORDS_PER_SECOND = 10
aql> SELECT * FROM test.demo
+--------+-----+-------+-------+
| PK | foo | bar | baz |
+--------+-----+-------+-------+
| "key1" | 123 | "abc" | true |
| "key3" | | "cde" | false |
| "key2" | 234 | "bcd" | false |
+--------+-----+-------+-------+
3 rows in set (0.080 secs)
OK
aql> Solution
RPS must be set on the client side to a value that is less than or equal to the read quota you’ve assigned your user. In the examples above, test was assigned 1000 read quotas. Therefore, the RPS I can give test is between 1-1000. If I assign test 0 RPS, we would exceed the quota. If I assign test 1001 RPS, we would exceed the quota.
Notes
-
When we do the PI or SI query, whatever we assigned as the RPS would be counted against the quota. From the example above, we can see that test.demo only contains 3 records. However, the RPS that was assigned is 10. Even though we only returned 3 records per second, the full 10 would be counted against the quota.
The example below shows user test with 10 read quota and RPS 10. As we can see, all 10 RPS was counted against the quota even though test.demo only contains 3 records.
aql> set scan_records_per_second 10 SCAN_RECORDS_PER_SECOND = 10 aql> select * from test.demo +--------+-----+-------+-------+ | PK | foo | bar | baz | +--------+-----+-------+-------+ | "key1" | 123 | "abc" | true | | "key3" | | "cde" | false | | "key2" | 234 | "bcd" | false | +--------+-----+-------+-------+ 3 rows in set (0.351 secs) OK [ 2025-08-25 17:26:04 'show users statistics' sleep: 2.0s iteration: 5 ] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Users Statistics (2025-08-25 17:26:04 UTC)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ User| Node|Connections|~~~~~~~~~~~~~~~~~~~~Read~~~~~~~~~~~~~~~~~~~|~~~~~~~~~~~~~~Write~~~~~~~~~~~~~~ | | | Quota| Usage%| Single| PI/SI| PI/SI| Quota| Single| PI/SI| PI/SI | | | | | Record| Query| Query| | Record| Query| Query | | | | | TPS| Limited|Limitless| | TPS|Limited|Limitless | | | | | | RPS| | | | RPS| admin|dc2-1:3000| 2.000 | 0.000 | --|0.000 | 0.000 | 0.000 |0.000 |0.000 |0.000 | 0.000 admin| | 2.000 | 0.000 | --|0.000 | 0.000 | 0.000 |0.000 |0.000 |0.000 | 0.000 test |dc2-1:3000| 2.000 |10.000 |100.0 %|0.000 |10.000 | 0.000 |0.000 |0.000 |0.000 | 0.000 test | | 2.000 |10.000 |100.0 %|0.000 |10.000 | 0.000 |0.000 |0.000 |0.000 | 0.000 Number of rows: 2 -
When using Aerospike 6.0+, scans were renamed to PI queries and queries were renamed to SI queries. To set an RPS for 6.0+, you would set it under the Statement Policy.
Java example:
Statement stmt = new Statement(); stmt.setRecordsPerSecond(2);