Mysql and Aerospike

php

#1

Hi!! I think make mysql in front to aerospike. mysql is for the structure. Mysql have tables, IDs tables and some fields for make search in fulltext, in aerospike have: duplicate id tables from mysql and same name sets from tables mysql and all data need inside aerospike…but only data for fulltext stend in mysql…I show you example of code…this code is good or is better another code for do more fast?

<?php
$config = [
    "hosts" => [
        ["addr" => "127.0.0.1", "port" => 3000]
    ]
];
$db = new Aerospike($config);
if (!$db->isConnected()) {
  echo "Failed to connect to the Aerospike server [{$db->errorno()}]: {$db->error()}\n";
  exit(1);
} else {
	echo "aerospike connessione ok</br>";
}
$mysqli = new mysqli("localhost","root","root","prova"); 
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  exit();
  } else {
   echo "mysql connessione ok</br>";
}
function outout_errors($error) {
    echo '<ul><li>',$error.'</li></ul>';
}
$result = $mysqli->query("SELECT idlingue FROM lingue limit 20");
while($row = $result->fetch_assoc()) {   
      $key = $db->initKey('jubecca', 'lingue', $row['idlingue']);
      $bins = array('lingua' => $row['lingua']);
   $status = $db->put($key, $bins);
	  $status = $db->get($key, $record);
	  echo "</br>Aerospike lingua: " . $record["bins"]["lingua"];
	  echo "</br>";	  
} 

  mysqli_close($mysqli);
  $db->close();
 ?>

#2

Makes much more sense to put Aerospike in front of MySQL, as it’s a much faster database, and read from MySQL only those things that it’s good at. Now if you’re thinking about full-text search, there really are much better products for than than MySQL, FYI.


#3

Thank for reply you are very gentle!! I write the message with a phone but the code, It was inserted badly.
Now I correct the code php.
I’m sorry but aerospike in front is like cache, right?
Maybe my problem is the relational db, but I see aerospike when I do the scan is slow(50ms/80ms), for record one by one is very fast, in php page need use scan for make a result, for example search a product, in set product and bin description, name need searching, so here the scan need, right? For this I think mysql in front but just with the structure id table and relation, maybe this way aside in front or not, is not good…For make a comparison prices what is better way(milions products, reviews, data for reports, stores, clicks…) with aerospike? Aerospike with lucene?solr?elasticsearch or something more?


#4

I personally would never use MySQL in front because it is a painful database for a production environment. There are places where using an RDBMS is the right tool for the job, but in many cases it is not. If you have a RESTful API you’re in a key-value use case, and it would make more sense to use a key-value store, such as Aerospike, rather than forcing an RDBMS like MySQL into a use-case that isn’t optimal. I had a talk on the topic.

With regarding to scans, there is an overhead for scanning with Aerospike that is noticeable on small data sets. If you have a large amount of data that overhead is really not an issue. I also have to question why you’d ever want to scan your whole set on anything but a backend analytics case. It makes more sense to build a secondary index and use that to retrieve the data you need, faster.

We discussed full-text searching before. I would personally use Solr, rather than MySQL. Even PostgreSQL has a better full-text implementation than MySQL.