Create a new namespace dynamically, without restart


#1

Originally created by susan » Wed Jul 02, 2014 3:37 pm

Create a new namespace dynamically, without restart Postby susan » Wed Jul 02, 2014 3:37 pm

There is a common question about creating new namespaces programmatically (client code) or without stopping the cluster. There are actually bigger design issues behind these questions.

The only way to create a new namespace is to add a stanza to the aerospike.conf file which requires the cluster to be restarted. This is because you need to identify the resources being used for the namespace (in-memory, in-memory with persistence, SSDs). The reason for using multiple namespaces is when you want to set the policy (disk vs RAM), TTL (Time to Live), or Replication Factor (how many copies of each record in the cluster, most of our customers use 2). If you must have multiple namespaces, some of our customers will create them in advance and leave them empty (note, it requires 1 GB memory for each namespace).

See the following URL for configuring a namespace. http://www.aerospike.com/docs/operations/configure/namespace/

You can often segment your data by using Sets which can be created dynamically, through client code. We used to use the analogy of a Set being analogous to a table, but that’s overly simplistic.

Say you have many client accounts, and you want to create a new Set for each client, cause after all, in a SQL environment you might have had a table for each client. Aerospike has a limit of 1023 Sets, so unless you limit your business to 1023 clients (which I hope is not the case), this is not a good way to think of Sets.

Instead, think of assigning a 6-8 digit number for each customer (which will give you 999,999 to 99,999,999 customers). If you want to further segment each customer by agents, campaigns so you assign another x digit that can be concatenated on to the customer code. You want to further segment by some other attribute like geographic region, assign a 3 digit code for 999 possible regions, etc.

Now you have a way of creating a lot of customer, agent, campaign records in the same Set. (NOTE: If you use this as your primary key and actually want to retrieve the pk value, you must put this as a value in one of the bins of the record. Aerospike only saves the digest - hashed value of your pk, not the pk itself). This also makes it possible to operate on all your records to do things like reports, aggregations, etc.


How to add a namespace in a production cluster
#2

If you want to dynamically create Namespace then you can do something like below-

  • Modify the aerospace.conf file on the server side .
  • Then restart the cluster which should restart all the nodes.
  • Done !

#3

The ability to add/remove namespaces with rolling restart of the cluster is added starting server version 3.13.0.1 for both Community and Enterprise versions on paxos-protocol version v5.

[AER-3485] - (KVS) Support adding/removing namespaces with rolling restart. http://www.aerospike.com/download/server/notes.html#3.13.0.1