REVIEW: IMPRESSED by the Rock Pi 4B

I just got my Rock Pi 4B… I had to have a friend bring it to me from China. Mother of god, I am IMPRESSED!! So look… I set up Ubuntu 18.01, PHP7.2 and Mysql 5.7 (I couldn’t get MySQL 8.0 set up on it). I skipped using the SD card (although I discovered you have an SD card in the Rock to make it use the M.2) and am instead using the Kingston KC1000 480GB M.2 SSD. It doesn’t disappoint!!

I ran a PHP script that randomizes data and inserts it into the localhost MySQL database. I ran these tests with the exact same script against my current 4 core, 8GB Digital Ocean droplet with PHP 7.2 and MySQL 8.0, and an identical droplet from Linode. I populated 200,001 rows and then another 200,001 rows of indexed data. THese plans cost me $40 per month, each. The Rock Pi was $75 USD, and I got the SSD for free.

The first think you are going to ask is "Did the Rock Pi outperform the the droplets? In short, the answer is: It was an epic battle! Absolutely incredible! I will post the scripts for PHP and MySql at the end so you can try it out yourself with your own setup, but let’s look at the numbers:
Writing:
Rock Pi Server:
Step 1:
Time to insert 200001 records: 368.8964
Average time per record = 0.0018444727776361
Step 2:
Time to insert 200001 records: 387.2555
Average time per record = 0.0019362678186609

Linode Server:
Step 1:
Time to insert 200001 records: 211.4915
Average time per record = 0.0010574522127389
Step 2:
Time to insert 200001 records: 184.0102
Average time per record = 0.000920046399768

Digital Ocean:
Step 1:
Time to insert 200001 records: 271.2323
Average time per record = 0.0013574522127389
Step 2:
Time to insert 200001 records: 266.9245
Average time per record = 0.0013346158399768

The Linode server was about 48% faster in writing and the Digital Ocean server was about 29% faster in writing. But NOT SO FAST! This can potentially be attributed to the fact MySql 8.0 is supposed to be up to TWICE as fast as MySQL 5.7. And if this is the case, the Rock PI might actually be faster up to 30% faster in performance! I can’t be sure, however, until I can get MySQL 8.0 running on the Rock.

Reading: SELECT Statement:
Reading is another matter altogether, and I am very happy about it.

I ran a geospatial query that is very heavy in math to determine what 1000 MAC addresses (out of the 400k) were in the closest proximity to a given point. First, it has to calculate every triangulation, discard every one not between 1 and 4 miles, and then order the first 1000. It’s a heavy-math query and the Rock crushed it! I will put the select query at the end. The results:
Linode: 1.939 seconds
Digital Ocean: 2.1217 seconds
Rock Pi: 1.688 seconds

WOW!!! It’s all I can say about that.

One thing… the Rock’s processor can get pretty darned hot. Yesterday, I loaded 88,000,000 rows of data onto it… and it was getting so hot I rested it so the processor was sitting on a silver spoon And so, I decided to do the rational thing… I fabricated a heat sink for it. Keep in mind, I will be making a server farm (one Rock PI for web requests, one Rock PI for databases and one additional Rock PI for mirroring the MySql database (in case of a failure). And so , my heat sink is big enough to be shared by all three of them. You can’t see it, but there is a chick of aluminum that joins the surface of the Rock’s processor to the face of the heat sink. Also, I used a chick of aluminum to cover the chips of the M.2 SSD to absorb some of the heat when it’s cranking away on long tasks. and it works GREAT!!!

Think about it: This little Rock pi is more potent than the 2U servers of just 5 years ago and is more potent that all but the biggest VPS’s out there. If you need data crunching on a budget, this little guy is your thing!

Here’s the PHP script I used… try it yourself on whatever hardware and see what your results are!

<?php
$database = include('Config/macs.php');
$db = mysqli_connect($database['host'], $database['user'], $database['pass'], $database['name']);
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();}
$logMacs = $db->prepare("INSERT INTO Macs (Mac, AcqDate, Lat, Lon) Values (?,NOW(), ?,?)");
$logMacs->bind_param('sdd', $mac, $lat, $lon);
$msc=microtime(true);
for ($x = 0; $x <= 200000; $x++) {
    $mac= implode(':', str_split(str_pad(base_convert(mt_rand(0, 0xffffff), 10, 16) . base_convert(mt_rand(0, 0xffffff), 10, 16), 12), 2));
    $lat = 38.914415+(rand(-14,14)*.01); $lon = -77.015264+(rand(-30,30)*.01);
    $logMacs->execute();}
$logMacs->close(); $db->close();
$msc=microtime(true)-$msc; $secs = round($msc,4); echo "Time to insert $x records:  $secs <br>";
echo "Average time per record = ".$secs/$x;

The code for the Database:
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
DROP TABLE IF EXISTS Macs;
CREATE TABLE Macs (
Mac char(17) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
AcqDate datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0),
Lat double(10, 8) NULL DEFAULT NULL,
Lon double(11, 8) NULL DEFAULT NULL,
INDEX Mac(Mac) USING BTREE,
INDEX Lat(Lat) USING BTREE,
INDEX Lon(Lon) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;

Select Query:
SELECT Mac, round(
(
3959 * acos(
(
(
(
cos(radians(38.914415)) * cos(
radians(Lat)
)
) * cos(
(
radians(Lon) - radians(-77.015264)
)
)
) + (
sin(radians(38.914415)) * sin(
radians(Lat)
)
)
)
)
),
1
) AS distance
FROM Macs
HAVING (distance BETWEEN 2 and 4)
ORDER BY
3959 * acos(
(
(
(
cos(radians(38.914415)) * cos(
radians(Lat)
)
) * cos(
(
radians(Lon) - radians(-77.015264)
)
)
) + (
sin(radians(38.914415)) * sin(
radians(Lat)
)
)
)
)
LIMIT 1000

3 Likes

While they are pretty impressive little machines, I would take those “benchmarks” with an ocean of salt. Comparing local metal to virtual servers is really not reasonable. There are too many factors that can cause impact on virtual server performance to make a meaningful benchmark on one. The first of which is the virtualization itself which kills a lot of performance. Further, system resource access is crippled both by the FACT of virtualization, as well as contention for the resources with other users of the host machine.

To suggest that…

Well, I’ve had my hands in physical servers for decades, and I’ll tell you straight up that a real metal server from more than a DECADE ago, will still outperform these in terms of number crunching. Maybe not disk I/O, because back then everything was still spinny magnets, but certainly in processing.

I actually still have a few servers in that age range, in fact. All upgraded with SSD’s now. They work marvelously still, and carry continuous loads that you simply could NOT do with an rk3399.

Still though, the rk3399 is impressive. For what it is.

2 Likes

Continuing the discussion from REVIEW: IMPRESSED by the Rock Pi 4B:

If it is to lead in concideration, the need for a user who does not have a server at home/office but who needs a server and will have two option a virtual service or the purchase of a server for their enterprise.
In these senary can be considered for the lowest cost benefit, have to evaluate the cost of electric power also, a server with Rock Pi 4 Nobreak vs. virtual server.
It would be interesting to develop a cost study.
It could start by becoming like feeding Rock I 4 with maximum energy efficiency.

Is gallium nitride the silicon of the future?

Lithium battery vs lead battery

Thanks for supplying your code. I was interested in comparing my odroid N2 (with slower SDD connected through USB3) with the results from your rock Pi 4 (with faster M.2). The N2 has advantage of faster processor but thought the speed of the Rock PI’s NVME would give it an advantage. But surprisngly the odroid N2 doesn’t do too bad at all. Time to insert 200001 records: 322.0876 Average time per record = 0.0016104299478503. The select statement completed in .555 seconds. The server was MariaDB 10.3.8 These little arm boards do certainly pack a punch.

Good article. thanks.

It isn’t even close. Its far cheaper to house your own arm servers by a long margin. Not sure the idle power of Rock Pi but imagine its very similar to Odroid N2 at ~2 watts. So looking at something between $2-5 electricity a year to operate. So basically I could buy a new arm sbc each year with the savings. BTW NGinx web server on arm is more than capable of saturing my LAN when pushed to the limits.