<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Times New Roman; font-size: 12pt; color: #000000'>I would say that that is a very good reason to try rolling your own. When you better understand what is going on inside an OTP gen_server then you can make a better choice of which way to go. Choosing to use a gen_server provides you with a lot of extra functionality and safety (for example calling the gen_server will check that it is there and doesn't die on you). However you do lose some control when receiving messages and there is an extra cost. You need to choose what you really need.<br><br>I am not advocating against using a gen_server, but I don't feel that you should indiscriminately always use one.<br><br>Robert<br><br><hr id="zwchr"><blockquote style="border-left:2px solid rgb(16, 16, 255);margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"James Rosenblum" <jrosenblum@prodigy.net><br><b>To: </b>"Gleb Peregud" <gleber.p@gmail.com><br><b>Cc: </b>"erlang-questions" <erlang-questions@erlang.org><br><b>Sent: </b>Sunday, 28 October, 2012 4:03:43 PM<br><b>Subject: </b>Re: [erlang-questions] Did I do it right?<br><br><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:14pt"><div><span>Gleb,</span></div><div style="color: rgb(0, 0, 0); font-size: 19px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 19px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span>Thanks for taking a look...</span></div><div style="color: rgb(0, 0, 0); font-size: 19px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 19px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span>I wanted to understand better what was going on with OTP, and I thought that rolling my own OTP-  Supervisor-compliant process would
 help. I thought that one day I might need to write my own. I sort of forgot that I did that - I will replace it with a gen-server. </span></div><div style="color: rgb(0, 0, 0); font-size: 19px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 19px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span><br></span></div><div><span></span></div><div><br></div>  <div style="font-family: arial, helvetica, sans-serif; font-size: 14pt; "> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt; "> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Gleb Peregud <gleber.p@gmail.com><br> <b><strong>To:</strong></b> James Rosenblum <jrosenblum@prodigy.net> <br><b><span style="font-weight: bold;">Cc:</span></b> erlang-questions <erlang-questions@erlang.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Saturday, October 27, 2012 3:53 AM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [erlang-questions] Did I do it right?<br> </font> </div> <br><div id="yiv1783588798">Hello James<div><br></div><div>Since no one reacted yet, I've skimmed through the code very quickly and it looks really good - I wouldn't assume it being written by Erlang novice. The only thing I've spotted, which is rarely done in production grade Erlang systems is use of non-OTP servers by doing manual looping in spawned process (although I can see it does handle all sys messages and stuff). Is there any particular reason to not use gen_server in that case?</div>
<div><br></div><div>Cheers,</div><div>Gleb Peregud<span></span><br><br>On Thursday, October 25, 2012, James Rosenblum  wrote:<br><blockquote class="yiv1783588798gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div style="font-size: 14pt; font-family: arial, helvetica, sans-serif; "><div style="font-family: arial, helvetica, sans-serif; font-size: 14pt; "><span style="font-size:12pt;">Kind and Wise List;</span><br>
</div><div style="font-family: arial, helvetica, sans-serif; "><div style=""><div><div><div><font size="3"><span></span></font><br><span style="font-size:12pt;"> For selfish and professional reasons, I regularly attempt medium-to-deep dives on interesting technologies (Ruby, Go, etc.), and about 12 months ago I started looking at Erlang. I have become a huge fan of the entire Erlang Ecosystem and have tried to be a good student. </span><br>
<font size="3"><span></span></font><br><span>Like many, I taught myself by reading the usual books, going to the usual websites, looking at existing projects, following this list and participating in stackoverflow.  And, like many I suspect, I wrote a cache ;)</span><br>
<font size="3"><span></span></font><br><span><font size="3">What I wrote could solve a problem for my company which builds and deploys an enterprise application which needs to cache domain-objects (assembled from a variety of Oracle or MSSQL tables) and provide them to web clients. We currently use an in-process cache that is part of a fairly typical Java-stack application. Unfortunately it is difficult to cluster, and it doesn't provide us with the level of control and specialization that we would like. A successful cache needs to be available on 2 or 3 nodes for redundancy and to handle load</font>. There are 200 - 400 clients producing about <font size="3">50 transactions per second bursting to about 200 transactions per second for a few minutes at a time (probably 80% reads). Our software is installed in customer's data centers - no public Internet involvement. What I wrote would seem to fulfill these
 requirements.</font></span><br>
<font size="3"><span></span></font><br><span style="font-size:12pt;">As a company, based on my enthusiasm, we are considering Erlang, and my cache is going to be looked at as a reference implementation, learning tool and poc. </span><br>
<font size="3"><span></span></font><br><span style="font-size:12pt;">What I don't know is: Did I create a piece of crap example of Erlang that does the entire community a disservice; or, did I do a reasonable job of representing what could, and should, be done with the technology?</span><br>
<font size="3"><span></span></font><br><span style="font-size:12pt;">If anyone is feeling charitable, and wouldn't mind helping develop a good Erlang Citizen, I would appreciate any comments or suggestions on what I have done. </span><br>
<font size="3"><span></span></font><br><span style="font-size:12pt;">It can be found at </span><span style="font-size:15px;line-height:19px;white-space:nowrap;"><a rel="nofollow" target="_blank" href="https://github.com/jr0senblum/JCache">https://github.com/jr0senblum/JCache</a></span></div>
<div style="font-size:12pt;"><font face=".HelveticaNeueUI"><span style="font-size:15px;line-height:19px;white-space:nowrap;"><br></span></font></div><div style="font-size:12pt;">
<font face=".HelveticaNeueUI"><span style="font-size:15px;line-height:19px;white-space:nowrap;">If this is an inappropriate request, I apologize and please feel free to ignore this all together.</span></font></div><div style="font-size:12pt;">
<font face=".HelveticaNeueUI"><span style="font-size:15px;line-height:19px;white-space:nowrap;"><br></span></font></div><div style="font-size:12pt;"><font face=".HelveticaNeueUI"><span style="font-size:15px;line-height:19px;white-space:nowrap;">Thanks in advance,<br>
</span></font><span></span><br><span>Jr0</span></div></div></div><br><br> </div> </div>  </div></div></blockquote></div>
</div><br><br> </div> </div>  </div><br>_______________________________________________<br>erlang-questions mailing list<br>erlang-questions@erlang.org<br>http://erlang.org/mailman/listinfo/erlang-questions<br></blockquote><br></div></body></html>