I have a spring application on heroku (seems like there is no way to use ehCache there). I found several projects on github like hibernate-memcached for the second level cache, but they have just few stars on github and I'm not sure if they are not buggy.
Would you recommend anything for java + hibernate 4 second level cache based on memcached?
https://github.com/kwon37xi/hibernate4-memcached
I made this.
One of heroku user sent me an email that he was using this library.
I have never been used heroku, but anyway I think this library work fine with heroku.
I heard heruku memcached requires authentication, refer to this wiki page https://github.com/kwon37xi/hibernate4-memcached/wiki/SpyMemcachedAdapter about authentication.
Related
We maintain our server once a week.
Sometimes, the customer wishes that we change some settings which is already cached in server.
My colleague always write some JSP code to change these settings which are stored in the memory.
Is it a good method to use this kind of methodology?
If our project is not a Web container, which tools can help me?
Usually, in my experience, the server configuration is not stored only in memory of server:
What happens that after a configuration change, the server has been restarted / just went down for some system reason?
What happens if you have more than one instance of the same server to work on (a cluster of servers in other words)?
So, usually, people opt for various "externalized configuration" options that can range from "file-based" configuration + redeploy the whole cluster upon each configuration change, to configuration management servers (like Consul, etc.d, etc). There are also some solutions that came from (and used in) a java world: Apache Zookeeper, Spring cloud config server to name a few, there are others. In addition, sometimes, it's convenient to store the configurations in a database.
Now to your question: If your project is not a web container and you don't care that configuration will "disappear" after a server restart and you're not running a distributed cluster of servers, then, using JSP indeed doesn't seem appropriate in this case.
Maybe you should take a look at JMX - Java management extensions, that have a built-in solution so that you probably will be able to get rid of a web container (which seems to be not used by your team anyway other than for JSP modifications that you've described).
You basically need in memory cache, there are multiple solutions found in answers which include creating your own implementation or using existing java library. You can also get data from database and add cache over the database layer.
My straight question is: let's say I have 10 wars deployed to my server. Inside of each one there is a simple job either coded with Spring Batch or JSR352 implementations. Then I want to start, check the status and stop them manually? What from an enterprise server would provide me that ability? For instance, let's say I have 10 batchs deployed to the same server (I use Websphere 8.5.5 ND with JDK 7 but you can have anyone in your mind). Five batchs are JSR-352 and others five are Spring Batch. I want to provide a single page for final user where he/she can start the server, see if it is running and then stop it while it is running (It is beyond this question talk about the front end side. It can be as simple a butom for start, another for stop and just refresh the page to see the current status). The question is focused in how to expose start/stop/status ability about Batchs deployed to a Web Server.
Let me explain a bit deeper. I have worked for the last 6 months in order to create few jobs with Spring Batch. For some reason, I can't start it straigh from unix shell or JCL in my company. In pratical terms it means I can't use a script starting it with command lines. I must use inside of our Websphere 8.5.5 ND. There is an amazing application named Spring Batch Admin that would fit my necessity but, to make short, I can't use it here.
It is beyond this question compare Spring Batch with JSR 352. For my question I really don't care which one I will use as long as I can offer someway for a monitor/operator/user to see in a web page someway to start/stop/check status. So if you can answer only for JSR 352 or only for Spring Batch it will be perfect. Obviously a bit better if there is some generic way to cover both.
I guess, not sure, that there might be someway to use JMX or JConsole feature to do something similar to what Spring Batch Admin does but I don't have the north and it is hard for me to start without a scratch direction. I am sure it is perfectly possible otherwise it wouldn't exist an application named Spring Batch Admin offering that (I have used it very well but I can't make it works in production for local reasons).
I think in JMX because I understand JMX can register beans and expose it and I think in JConsole from the Java used for my server because it shows what is going on with the same JVM used for that server.
Readers that got interested in this question but didn't understand what I mean by JSR 352 or Spring Batch Admin may get interested in this two links:
JSR352 in Websphere ND
http://www-01.ibm.com/support/docview.wss?uid=tss1wp102544&aid=1
Spring Batch Admin
https://examples.javacodegeeks.com/enterprise-java/spring/spring-batch-admin-tutorial/
Very interested movie convering both implementations:
https://www.youtube.com/watch?v=yKs4yPs-5yU
I would like to put in spot light that answer that try to compare Spring Batch with JSR352 I will downgrade the answer. It is very far away from my question and motivation.
I've created some REST endpoints using pure Groovy/Grails. For now most of the operations are all CRUD-like.
I'm beginning to compare the performance of the Grails app to an equivalent Java/Spring app for the CRUD scenarios that I've made, using JMeter. So now I'm taking a subset of the scenarios I've implemented in Grails and porting to a basic Spring MVC app.
I'm very interested in seeing performance comparisons published by others on the web. Can anyone refer me to some?
Any other information in regards to the testing and analysis I'm going to do is welcome. Thanks!
UPDATE REGARDING THE ANSWER:
#Lari's answer below references a website with extremely comprehensive tests, comparing Grails 2.X vs Spring 4.X (see README.md), in addition to a multitude of other frameworks.
However, those tests have Grails running on Resin while Spring is on Tomcat. A little strange to me since Grails uses Tomcat by default.
Resin and Tomcat arguably have similar performance.
The website has several sections (tabs on top) and even subsections (tabs in the "Results" area). My original question was regarding web service behavior for REST. To that end here are the top-level sections that answered my question:
Querying multiple rows in a DB table (HTTP GET) and returning JSON array as result.
Modifying multiple rows in a DB table and returning JSON array as result. This test does not use HTTP PUT with a body, but instead HTTP GET. Scroll to bottom of page for details, and also Requirements page.
If you're interested in HTML rendering see the Fortune Cookie example.
Not surprisingly Spring is better, but like #Joshua points out, this is a contrived example and you will have to be the judge of what to extrapolate from the results. Not to mention that Grails used Resin while Spring used Tomcat. Hopefully each server (Tomcat / Resin) was configured similarly in terms of max threads, Java memory, etc? The config files may be buried in the source code (if you find out, let me know).
I also setup dummy applications for Spring 4.X vs Grails 2.X, with Tomcat being configured exactly the same (both used the same standalone Tomcat installation rather than one bundled inside Grails). In my tests I performed an HTTP GET and returned a JSON array which was formed using static (pre-instantiated) in-memory objects (no DB query). My results also showed better performance for Spring (sorry I can't find my data any longer!). I used Spring Boot to slap a Spring app together quickly, and Grails already has scaffolding by default.
There is http://www.techempower.com/benchmarks/ . The source code is at github.
Take a look at this PLAY VS. GRAILS SMACKDOWN presentation. You can find some results of perfomance inside.
Is it possible (and does it make sense) to use the JDO Level 2 Cache for the Google App Engine Datastore?
First of all, why is there no documentation about this on Google's pages? Are there some problems with it? Do we need to set up limits to protect our memcache quota?
According to DataNucleus on Stackoverflow, you can set the following persistence properties:
datanucleus.cache.level2.type=javax.cache
datanucleus.cache.level2.cacheName={cache name}
Is that all? Can we choose any cache name?
Other sources on the Internet report using different settings.
Also, it seems we need to download the DataNucleus Cache support plugin. Which version would be appropriate? And do we just place it in WEB-INF/lib or does it need more setup to activate it?
Before you can figure this out, you have to answer one question:
Which version of DataNucleus are you using?
Everything on this post has to do with the old version of the plugin -- v1. Only recently has the Google Plugin for Eclipse supported v2 of the DataNucleus plugin for AppEngine (which is basically the conduit between AppEngine and the DataNucleus Core).
I'd recommend upgrading to v2 of the Datanucleus plugin for AppEngine -- if you're using Eclipse, it's easy -- there's a UI for it that allows you to select v1 or v2. Just go to your Project properties and find the App Engine settings and look for "Datanucleus JDO/JPA version".
Plus, you have to make a change to your jdo-config.xml. Specifically, you have to change just one property:
<property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
SO -- Once you've upgraded to v2, this is how you specify caching (an addition to jdoconfig.xml):
<property name="datanucleus.cache.level2.type" value="jcache"/>
<property name="datanucleus.cache.level2.cacheName" value="NameItWhateverYouWant"/>
At this point, caching should happen automatically every time you put and get using a PersistenceManager. Hooray!
No known problems with anything to do with L2 caching and GAE/J. If people have problems then perhaps they ought to report them to Google. Set the cache name to what you wish. Anything put into memcache has to be Serializable, obviously, since that is what memcache does. Yes, you need the datanucleus-cache plugin (ver 1.x), and put it in the same place as any other DN jars. One day Google will update to use DN 2.x
It seems to have problems instead: I tried (with JPA) and I got the error someone else already reported: http://code.google.com/p/datanucleus-appengine/issues/detail?id=163
What if you don't want to start a separate project for grails but instead sneak it into an existing webapp?
I have to build an admin interface/crud for some new entities and thought it would be a perfect way to learn grails.
I'm trying to make one application with a Grails app and a Spring app.
I've tried to sneak the Grails App into the Spring one, but this is "impossible". It's easier to sneak the Spring app into the Grails app. Grails knows what Spring is, but Spring has no idea of what Grails is.
In this article you can find useful information about how to use your hibernate mapping files or annotations in Grails, so you don't have to remap everything. Also you can use all your java clases (put them into src/java). You can put the beans defined in the ApplicationContext.xml in conf/spring/resources.xml. You can leave them in ApplicationContext, but I've had some problems.
I don't have ended the job (almost) and it looks good.
It would be hard to "sneak it in" unless the existing app has the correct dir structure that maps exactly to how grails likes it - after all, convention over config is where the power of grails comes from.
You can try doing the admin interface as a "seperate" app to the original/existing spring app, and map the existing database to the grails domain objects. though i m not sure how you would run them side by side easily without more information on the existing app. It is possible definitely though.
I agree that building your admin interface is a good exercise to learn Grails, and also agree with the previous answer that Grails is difficult if not impossible to integrate with an existing Spring application. You could probably get it done, but the headache would not be worth it.
Grails is built on top of Hibernate for its ORM, so if you're already using Hibernate with this Spring app you can work this to your advantage. It's not too difficult to configure a Grails app to use pre-existing Hibernate models, and this is explained well in Grails documentation.
So, I'd recommend building up your admin console as an independent Grails app but make use of the Hibernate models you already have, if in fact you've used Hibernate.