{"id":297,"date":"2010-07-23T03:05:00","date_gmt":"2010-07-23T03:05:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/java-best-practices-high-performance-serialization.html"},"modified":"2012-10-21T19:16:31","modified_gmt":"2012-10-21T19:16:31","slug":"java-best-practices-high-performance","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html","title":{"rendered":"Java Best Practices \u2013 High performance Serialization"},"content":{"rendered":"<p>Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate how to utilize Object Serialization for high performance applications.<\/p>\n<p>All discussed topics are based on use cases derived from the development of mission critical, ultra high performance production systems for the telecommunication industry.<\/p>\n<p>Prior reading each section of this article it is highly recommended that you consult the relevant Java API documentation for detailed information and code samples.<\/p>\n<p>All tests are performed against a Sony Vaio with the following characteristics :<\/p>\n<ul>\n<li>System : openSUSE 11.1 (x86_64)<\/li>\n<li>Processor (CPU) : Intel(R) Core(TM)2 Duo CPU T6670 @ 2.20GHz<\/li>\n<li>Processor Speed : 1,200.00 MHz<\/li>\n<li>Total memory (RAM) : 2.8 GB<\/li>\n<li>Java : OpenJDK 1.6.0_0 64-Bit <\/li>\n<\/ul>\n<p>The following test configuration is applied :<\/p>\n<ul>\n<li>Concurrent worker Threads : 200<\/li>\n<li>Test repeats per worker Thread : 1000<\/li>\n<li>Overall test runs : 100 <\/li>\n<\/ul>\n<p><span style=\"font-size: large\"><strong>High performance Serialization<\/strong><\/span><\/p>\n<p>Serialization is the process of converting an object into a stream of bytes. That stream can then be sent through a socket, stored to a file and\/or database or simply manipulated as is. With this article we do not intend to present an in depth description of the serialization mechanism, there are numerous articles out there that provide this kind of information. What will be discussed here is our proposition for utilizing serialization in order to achieve high performance results.<\/p>\n<p>The three main performance problems with serialization are : <\/p>\n<ul>\n<li>Serialization is a recursive algorithm. Starting from  a single object, all the objects that can be reached from that object by following instance variables, are also serialized. The default behavior can easily lead to unnecessary Serialization overheads<\/li>\n<li>Both serializing and deserializing require the serialization mechanism to discover information about the instance it is serializing. Using the default serialization mechanism, will use reflection to discover all the field values. Furthermore if you don&#8217;t explicitelly set a \u201eserialVersionUID\u201c class attribute, the serialization mechanism has to compute it. This involves going through all the fields and methods to generate a hash. The aforementioned procedure can be quite slow<\/li>\n<li>Using the default serialization mechanism, all the serializing class description information is included in the stream, such as :<\/li>\n<ul>\n<li>The description of all the serializable superclasses<\/li>\n<li>The description of the class itself<\/li>\n<li>The instance data associated with the specific instance of the class<\/li>\n<\/ul>\n<\/ul>\n<p>To solve the aforementioned performance problems you can use Externalization instead. The major difference between these two methods is that Serialization writes out class descriptions of all the serializable superclasses along with the information associated with the instance when viewed as an instance of each individual superclass. Externalization, on the other hand, writes out the identity of the class (the name of the class and the appropriate \u201eserialVersionUID\u201c class attribute) along with the superclass structure and all the information about the class hierarchy. In other words, it stores all the metadata, but writes out only the local instance information. In short, Externalization eliminates almost all the reflective calls used by the serialization mechanism and gives you complete control over the marshalling and demarshalling algorithms, resulting in dramatic performance improvements.<\/p>\n<p>Of course, Externalization efficiency comes at a price. The default serialization mechanism adapts to application changes due to the fact that metadata is automatically extracted from the class definitions. Externalization on the other hand isn&#8217;t very flexible and requires you to rewrite your marshalling and demarshalling code whenever you change your class definitions.<\/p>\n<p>What follows is a short demonstration on how to utilize Externalization for high performance applications. We will start by providing the \u201cEmployee\u201d object to perform serialization and deserialization operations. Two flavors of the \u201cEmployee\u201d object will be used. One suitable for standard serialization operations and another that is modified so as to able to be externalized.<\/p>\n<p>Below is the first flavor of the \u201cEmployee\u201d object :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.test;\r\n\r\nimport java.io.Serializable;\r\nimport java.util.Date;\r\nimport java.util.List;\r\n\r\npublic class Employee implements Serializable {\r\n\r\n private static final long serialVersionUID = 3657773293974543890L;\r\n \r\n private String firstName;\r\n private String lastName;\r\n private String socialSecurityNumber;\r\n private String department;\r\n private String position;\r\n private Date hireDate;\r\n private Double salary;\r\n private Employee supervisor;\r\n private List&lt;string&gt; phoneNumbers;\r\n \r\n public Employee() {\r\n }\r\n \r\n public Employee(String firstName, String lastName,\r\n   String socialSecurityNumber, String department, String position,\r\n   Date hireDate, Double salary) {\r\n  this.firstName = firstName;\r\n  this.lastName = lastName;\r\n  this.socialSecurityNumber = socialSecurityNumber;\r\n  this.department = department;\r\n  this.position = position;\r\n  this.hireDate = hireDate;\r\n  this.salary = salary;\r\n }\r\n\r\n public String getFirstName() {\r\n  return firstName;\r\n }\r\n\r\n public void setFirstName(String firstName) {\r\n  this.firstName = firstName;\r\n }\r\n\r\n public String getLastName() {\r\n  return lastName;\r\n }\r\n\r\n public void setLastName(String lastName) {\r\n  this.lastName = lastName;\r\n }\r\n\r\n public String getSocialSecurityNumber() {\r\n  return socialSecurityNumber;\r\n }\r\n\r\n public void setSocialSecurityNumber(String socialSecurityNumber) {\r\n  this.socialSecurityNumber = socialSecurityNumber;\r\n }\r\n\r\n public String getDepartment() {\r\n  return department;\r\n }\r\n\r\n public void setDepartment(String department) {\r\n  this.department = department;\r\n }\r\n\r\n public String getPosition() {\r\n  return position;\r\n }\r\n\r\n public void setPosition(String position) {\r\n  this.position = position;\r\n }\r\n\r\n public Date getHireDate() {\r\n  return hireDate;\r\n }\r\n\r\n public void setHireDate(Date hireDate) {\r\n  this.hireDate = hireDate;\r\n }\r\n\r\n public Double getSalary() {\r\n  return salary;\r\n }\r\n\r\n public void setSalary(Double salary) {\r\n  this.salary = salary;\r\n }\r\n\r\n public Employee getSupervisor() {\r\n  return supervisor;\r\n }\r\n\r\n public void setSupervisor(Employee supervisor) {\r\n  this.supervisor = supervisor;\r\n }\r\n\r\n public List&lt;string&gt; getPhoneNumbers() {\r\n  return phoneNumbers;\r\n }\r\n\r\n public void setPhoneNumbers(List&lt;string&gt; phoneNumbers) {\r\n  this.phoneNumbers = phoneNumbers;\r\n }\r\n\r\n}\r\n<\/pre>\n<p>Things to notice here :<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li>We assume that the following fields are mandatory :<\/li>\n<ul>\n<li>\u201cfirstName\u201d<\/li>\n<li>\u201clastName\u201d<\/li>\n<li>\u201csocialSecurityNumber\u201d<\/li>\n<li>\u201cdepartment\u201d<\/li>\n<li>\u201cposition\u201d<\/li>\n<li>\u201chireDate\u201d<\/li>\n<li>\u201csalary\u201d<\/li>\n<\/ul>\n<\/ul>\n<p>Following is the second flavor of the \u201cEmployee\u201d object :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.test;\r\n\r\nimport java.io.Externalizable;\r\nimport java.io.IOException;\r\nimport java.io.ObjectInput;\r\nimport java.io.ObjectOutput;\r\nimport java.util.Arrays;\r\nimport java.util.Date;\r\nimport java.util.List;\r\n\r\npublic class Employee implements Externalizable {\r\n\r\n private String firstName;\r\n private String lastName;\r\n private String socialSecurityNumber;\r\n private String department;\r\n private String position;\r\n private Date hireDate;\r\n private Double salary;\r\n private Employee supervisor;\r\n private List&lt;string&gt; phoneNumbers;\r\n \r\n public Employee() {\r\n }\r\n \r\n public Employee(String firstName, String lastName,\r\n   String socialSecurityNumber, String department, String position,\r\n   Date hireDate, Double salary) {\r\n  this.firstName = firstName;\r\n  this.lastName = lastName;\r\n  this.socialSecurityNumber = socialSecurityNumber;\r\n  this.department = department;\r\n  this.position = position;\r\n  this.hireDate = hireDate;\r\n  this.salary = salary;\r\n }\r\n\r\n public String getFirstName() {\r\n  return firstName;\r\n }\r\n\r\n public void setFirstName(String firstName) {\r\n  this.firstName = firstName;\r\n }\r\n\r\n public String getLastName() {\r\n  return lastName;\r\n }\r\n\r\n public void setLastName(String lastName) {\r\n  this.lastName = lastName;\r\n }\r\n\r\n public String getSocialSecurityNumber() {\r\n  return socialSecurityNumber;\r\n }\r\n\r\n public void setSocialSecurityNumber(String socialSecurityNumber) {\r\n  this.socialSecurityNumber = socialSecurityNumber;\r\n }\r\n\r\n public String getDepartment() {\r\n  return department;\r\n }\r\n\r\n public void setDepartment(String department) {\r\n  this.department = department;\r\n }\r\n\r\n public String getPosition() {\r\n  return position;\r\n }\r\n\r\n public void setPosition(String position) {\r\n  this.position = position;\r\n }\r\n\r\n public Date getHireDate() {\r\n  return hireDate;\r\n }\r\n\r\n public void setHireDate(Date hireDate) {\r\n  this.hireDate = hireDate;\r\n }\r\n\r\n public Double getSalary() {\r\n  return salary;\r\n }\r\n\r\n public void setSalary(Double salary) {\r\n  this.salary = salary;\r\n }\r\n\r\n public Employee getSupervisor() {\r\n  return supervisor;\r\n }\r\n\r\n public void setSupervisor(Employee supervisor) {\r\n  this.supervisor = supervisor;\r\n }\r\n\r\n public List&lt;string&gt; getPhoneNumbers() {\r\n  return phoneNumbers;\r\n }\r\n\r\n public void setPhoneNumbers(List&lt;string&gt; phoneNumbers) {\r\n  this.phoneNumbers = phoneNumbers;\r\n }\r\n\r\n public void readExternal(ObjectInput objectInput) throws IOException,\r\n   ClassNotFoundException {\r\n  \r\n  this.firstName = objectInput.readUTF();\r\n  this.lastName = objectInput.readUTF();\r\n  this.socialSecurityNumber = objectInput.readUTF();\r\n  this.department = objectInput.readUTF();\r\n  this.position = objectInput.readUTF();\r\n  this.hireDate = new Date(objectInput.readLong());\r\n  this.salary = objectInput.readDouble();\r\n  \r\n  int attributeCount = objectInput.read();\r\n\r\n  byte[] attributes = new byte[attributeCount];\r\n\r\n  objectInput.readFully(attributes);\r\n  \r\n  for (int i = 0; i &lt; attributeCount; i++) {\r\n   byte attribute = attributes[i];\r\n\r\n   switch (attribute) {\r\n   case (byte) 0:\r\n    this.supervisor = (Employee) objectInput.readObject();\r\n    break;\r\n   case (byte) 1:\r\n    this.phoneNumbers = Arrays.asList(objectInput.readUTF().split(\";\"));\r\n    break;\r\n   }\r\n  }\r\n  \r\n }\r\n\r\n public void writeExternal(ObjectOutput objectOutput) throws IOException {\r\n  \r\n  objectOutput.writeUTF(firstName);\r\n  objectOutput.writeUTF(lastName);\r\n  objectOutput.writeUTF(socialSecurityNumber);\r\n  objectOutput.writeUTF(department);\r\n  objectOutput.writeUTF(position);\r\n  objectOutput.writeLong(hireDate.getTime());\r\n  objectOutput.writeDouble(salary);\r\n  \r\n  byte[] attributeFlags = new byte[2];\r\n  \r\n  int attributeCount = 0;\r\n  \r\n  if (supervisor != null) {\r\n   attributeFlags[0] = (byte) 1;\r\n   attributeCount++;\r\n  }\r\n  if (phoneNumbers != null &amp;&amp; !phoneNumbers.isEmpty()) {\r\n   attributeFlags[1] = (byte) 1;\r\n   attributeCount++;\r\n  }\r\n  \r\n  objectOutput.write(attributeCount);\r\n  \r\n  byte[] attributes = new byte[attributeCount];\r\n\r\n  int j = attributeCount;\r\n\r\n  for (int i = 0; i &lt; 2; i++)\r\n   if (attributeFlags[i] == (byte) 1) {\r\n    j--;\r\n    attributes[j] = (byte) i;\r\n   }\r\n\r\n  objectOutput.write(attributes);\r\n  \r\n  for (int i = 0; i &lt; attributeCount; i++) {\r\n   byte attribute = attributes[i];\r\n\r\n   switch (attribute) {\r\n   case (byte) 0:\r\n    objectOutput.writeObject(supervisor);\r\n    break;\r\n   case (byte) 1:\r\n    StringBuilder rowPhoneNumbers = new StringBuilder();\r\n    for(int k = 0; k &lt; phoneNumbers.size(); k++)\r\n     rowPhoneNumbers.append(phoneNumbers.get(k) + \";\");\r\n    rowPhoneNumbers.deleteCharAt(rowPhoneNumbers.lastIndexOf(\";\"));\r\n    objectOutput.writeUTF(rowPhoneNumbers.toString());\r\n    break;\r\n   }\r\n  }\r\n  \r\n }\r\n}\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ul>\n<li>We implement the \u201cwriteExternal\u201d method for marshalling the \u201cEmployee\u201d object. All mandatory fields are written to the stream<\/li>\n<li>For the \u201chireDate\u201d field we write only the number of milliseconds represented by this Date object. Assuming that the demarshaller will be using the same timezone as the marshaller the milliseconds value is all the information we need to properly deserialize the \u201chireDate\u201d field. Keep in mind that we could serialize the entire \u201chireDate\u201d object by using the \u201cobjectOutput.writeObject(hireDate)\u201d operation. In that case the default serialization mechanism would kick in resulting in speed degradation and size increment for the resulting stream<\/li>\n<li>All the non mandatory fields (\u201csupervisor\u201d and \u201cphoneNumbers\u201d) are written to the stream only when they have actual (not null) values. To implement this functionality we use the \u201cattributeFlags\u201d and \u201cattributes\u201d byte arrays. Each position of the \u201cattributeFlags\u201d array represents a non mandatory field and holds a \u201cmarker\u201d indicating whether the specific field has a value. We check each non mandatory field and populate the \u201cattributeFlags\u201d byte array with the corresponding markers. The \u201cattributes\u201d byte array indicates the actual non mandatory fields that must be written to the stream by means of \u201cposition\u201d. For example if both \u201csupervisor\u201d and \u201cphoneNumbers\u201d non mandatory fields have actual values then \u201cattributeFlags\u201d byte array should be [1,1] and \u201cattributes\u201d byte array should be [0,1]. In case only \u201cphoneNumbers\u201d non mandatory field has a non null value \u201cattributeFlags\u201d byte array should be [0,1] and \u201cattributes\u201d byte array should be [1]. By using the aforementioned algorithm we can achieve minimal size footprint for the resulting stream. To properly deserialize the \u201cEmployee\u201d object non mandatory parameters we must write to the steam only the following information :<\/li>\n<ul>\n<li>The overall number of non mandatory parameters that will be written (aka the \u201cattributes\u201d byte array size \u2013 for the demarshaller to parse)<\/li>\n<li>The \u201cattributes\u201d byte array (for the demarshaller to properly assign field values)<\/li>\n<li>The actual non mandatory parameter values<\/li>\n<\/ul>\n<li>For the \u201cphoneNumbers\u201d field we construct and write to the stream a String representation of its contents. Alternatively we could serialize the entire \u201cphoneNumbers\u201d object by using the \u201cobjectOutput.writeObject(phoneNumbers)\u201d operation. In that case the default serialization mechanism would kick in resulting in speed degradation and size increment for the resulting stream<\/li>\n<li>We implement the \u201creadExternal\u201d method for demarshalling the \u201cEmployee\u201d object. All mandatory fields are written to the stream. For the non mandatory fields the demarshaller assigns the appropriate field values according to the protocol described above<\/li>\n<\/ul>\n<p>For the serialization and deserialization processes we used the following four functions. These functions come in two flavors. The first pair is suitable for serializing and deserializing Externalizable object instances, whereas the second pair is suitable for serializing and deserializing Serializable object instances.<\/p>\n<pre class=\"brush: java\">public static byte[][] serializeObject(Externalizable object) throws Exception {\r\n  ByteArrayOutputStream baos = null;\r\n  ObjectOutputStream oos = null;\r\n  byte[][] res = new byte[2][];\r\n  \r\n  try {\r\n   baos = new ByteArrayOutputStream();\r\n   oos = new ObjectOutputStream(baos);\r\n   \r\n   object.writeExternal(oos);\r\n   oos.flush();\r\n   \r\n   res[0] = object.getClass().getName().getBytes();\r\n   res[1] = baos.toByteArray();\r\n  \r\n  } catch (Exception ex) {\r\n   throw ex;\r\n  } finally {\r\n   try {\r\n    if(oos != null)\r\n     oos.close();\r\n   } catch (Exception e) {\r\n    e.printStackTrace();\r\n   }\r\n  }\r\n  \r\n  return res;\r\n }\r\n <\/pre>\n<pre class=\"brush: java\">public static Externalizable deserializeObject(byte[][] rowObject) throws Exception {\r\n  ObjectInputStream ois = null;\r\n  String objectClassName = null;\r\n  Externalizable res = null;\r\n  \r\n  try {\r\n   \r\n   objectClassName = new String(rowObject[0]);\r\n   byte[] objectBytes = rowObject[1];\r\n   \r\n   ois = new ObjectInputStream(new ByteArrayInputStream(objectBytes));\r\n   \r\n   Class objectClass = Class.forName(objectClassName);\r\n   res = (Externalizable) objectClass.newInstance();\r\n   res.readExternal(ois);\r\n  \r\n  } catch (Exception ex) {\r\n   throw ex;\r\n  } finally {\r\n   try {\r\n    if(ois != null)\r\n     ois.close();\r\n   } catch (Exception e) {\r\n    e.printStackTrace();\r\n   }\r\n   \r\n  }\r\n  \r\n  return res;\r\n  \r\n }\r\n <\/pre>\n<pre class=\"brush: java\">public static byte[] serializeObject(Serializable object) throws Exception {\r\n  ByteArrayOutputStream baos = null;\r\n  ObjectOutputStream oos = null;\r\n  byte[] res = null;\r\n  \r\n  try {\r\n   baos = new ByteArrayOutputStream();\r\n   oos = new ObjectOutputStream(baos);\r\n   \r\n   oos.writeObject(object);\r\n   oos.flush();\r\n   \r\n   res = baos.toByteArray();\r\n  \r\n  } catch (Exception ex) {\r\n   throw ex;\r\n  } finally {\r\n   try {\r\n    if(oos != null)\r\n     oos.close();\r\n   } catch (Exception e) {\r\n    e.printStackTrace();\r\n   }\r\n  }\r\n  \r\n  return res;\r\n }\r\n <\/pre>\n<pre class=\"brush: java\">public static Serializable deserializeObject(byte[] rowObject) throws Exception {\r\n  ObjectInputStream ois = null;\r\n  Serializable res = null;\r\n  \r\n  try {\r\n   \r\n   ois = new ObjectInputStream(new ByteArrayInputStream(rowObject));\r\n   res = (Serializable) ois.readObject();\r\n  \r\n  } catch (Exception ex) {\r\n   throw ex;\r\n  } finally {\r\n   try {\r\n    if(ois != null)\r\n     ois.close();\r\n   } catch (Exception e) {\r\n    e.printStackTrace();\r\n   }\r\n   \r\n  }\r\n  \r\n  return res;\r\n  \r\n }\r\n<\/pre>\n<p>Below we present a performance comparison chart between the two aforementioned approaches<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/_tWwHCKnIbjs\/TEjb2DwuMlI\/AAAAAAAAAAU\/wjLqxXdQdy0\/s1600\/chart.png\"><img decoding=\"async\" border=\"0\" height=\"203\" src=\"http:\/\/1.bp.blogspot.com\/_tWwHCKnIbjs\/TEjb2DwuMlI\/AAAAAAAAAAU\/wjLqxXdQdy0\/s400\/chart.png\" width=\"400\" \/><\/a><\/div>\n<p>The horizontal axis represents the number of test runs and the vertical axis the average transactions per second (TPS) for each test run. Thus higher values are better. As you can see by using the  Externalizable approach you can achieve superior performance gains when serializing and deserializing compared to the plain Serializable approach. <\/p>\n<p>Lastly we must pinpoint that we performed our tests providing values for all non mandatory fields of the \u201cEmployee\u201d object. You should expect even higher performance gains if you do not use all the non mandatory parameters for your tests, either when comparing between the same approach and most importantly when cross comparing between the Externalizable and Serializable approaches.<\/p>\n<p>Happy coding!<\/p>\n<p>Justin<\/p>\n<div style=\"margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html\">Java Best Practices \u2013 DateFormat in a Multithreading Environment<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/08\/java-best-practices-vector-arraylist.html\">Java Best Practices \u2013 Vector vs ArrayList vs HashSet<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/string-performance-exact-string.html\">Java Best Practices \u2013 String performance and Exact String Matching<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/java-best-practices-queue-battle-and.html\">Java Best Practices \u2013 Queue battle and the Linked ConcurrentHashMap<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/11\/java-best-practices-char-to-byte-and.html\">Java Best Practices \u2013 Char to Byte and Byte to Char conversions<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate how to utilize Object Serialization for high performance applications. All discussed topics are based on use cases derived from the development of mission critical, ultra high performance production systems for the telecommunication industry. &hellip;<\/p>\n","protected":false},"author":4,"featured_media":148,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[66,65],"class_list":["post-297","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-java-best-practices","tag-serialization"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Best Practices \u2013 High performance Serialization - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Best Practices \u2013 High performance Serialization - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2010-07-23T03:05:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T19:16:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Byron Kiourtzoglou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Byron Kiourtzoglou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html\"},\"author\":{\"name\":\"Byron Kiourtzoglou\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9c0c8d27141b068173953202dd9aebeb\"},\"headline\":\"Java Best Practices \u2013 High performance Serialization\",\"datePublished\":\"2010-07-23T03:05:00+00:00\",\"dateModified\":\"2012-10-21T19:16:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html\"},\"wordCount\":1280,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"keywords\":[\"Java Best Practices\",\"Serialization\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html\",\"name\":\"Java Best Practices \u2013 High performance Serialization - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"datePublished\":\"2010-07-23T03:05:00+00:00\",\"dateModified\":\"2012-10-21T19:16:31+00:00\",\"description\":\"Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-high-performance.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/core-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Java Best Practices \u2013 High performance Serialization\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9c0c8d27141b068173953202dd9aebeb\",\"name\":\"Byron Kiourtzoglou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"caption\":\"Byron Kiourtzoglou\"},\"description\":\"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\\\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"https:\\\/\\\/www.pivotalgamers.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/byron-kiourtzoglou-530ab222\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/byron-kiourtzoglou\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Best Practices \u2013 High performance Serialization - Java Code Geeks","description":"Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html","og_locale":"en_US","og_type":"article","og_title":"Java Best Practices \u2013 High performance Serialization - Java Code Geeks","og_description":"Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate","og_url":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2010-07-23T03:05:00+00:00","article_modified_time":"2012-10-21T19:16:31+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","type":"image\/jpeg"}],"author":"Byron Kiourtzoglou","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Byron Kiourtzoglou","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html"},"author":{"name":"Byron Kiourtzoglou","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9c0c8d27141b068173953202dd9aebeb"},"headline":"Java Best Practices \u2013 High performance Serialization","datePublished":"2010-07-23T03:05:00+00:00","dateModified":"2012-10-21T19:16:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html"},"wordCount":1280,"commentCount":8,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","keywords":["Java Best Practices","Serialization"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html","url":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html","name":"Java Best Practices \u2013 High performance Serialization - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","datePublished":"2010-07-23T03:05:00+00:00","dateModified":"2012-10-21T19:16:31+00:00","description":"Continuing our series of articles concerning proposed practices while working with the Java programming language, we are going to discuss and demonstrate","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/core-java"},{"@type":"ListItem","position":4,"name":"Java Best Practices \u2013 High performance Serialization"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9c0c8d27141b068173953202dd9aebeb","name":"Byron Kiourtzoglou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","caption":"Byron Kiourtzoglou"},"description":"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.","sameAs":["https:\/\/www.pivotalgamers.com\/","https:\/\/www.linkedin.com\/in\/byron-kiourtzoglou-530ab222"],"url":"https:\/\/www.javacodegeeks.com\/author\/byron-kiourtzoglou"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/297","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=297"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/148"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}