Just curious - are the writes cheaper now, or is it still the same?
On Aug 25, 8:09 am, sree <sraj...@gmail.com> wrote:
> Thanks for your reply.
>
> My app id is my-sree.appspot.com. I have only 1 index defined on a
> date property.
>
> We get 6.5 hours of cpu time each reset on a daily basis. Do both
> cpu_ms and api_cpu_ms gets counted for this? My app requires a lot of
> writes and hence I want to optimize for best performance. I have very
> few indexes created as well. And on a average my entity has around 10
> properties.
>
> On Aug 21, 8:39 pm, Don Schwarz <schwa...@google.com> wrote:
>
> > What is your app id? Do you have a large number of indexes defined for this
> > entity kind?
>
> > FYI, it's certainly a good idea to optimize for performance, but I wouldn't
> > worry too much about the particular point at which warnings appear in the
> > request logs. These are just guidelines to let you know which requests are
> > consuming the most CPU. If you're only planning to update these entities on
> > a fraction of your requests then the overall CPU cost should not be too
> > high. However, if your application is doing a lot of writes then by all
> > means, try to optimize this (e.g. by reducing the number of indexes, or
> > perhaps by reducing the number of columns if you don't query them
> > independently).
>
> > On Fri, Aug 21, 2009 at 6:55 AM, sree <sraj...@gmail.com> wrote:
>
> > > In a test app I have created, I am able to insert only 2 rows per
> > > request (for 1 entity with 10 properties only) into the datastore by
> > > using low-level api without getting any warnings for cpu_ms /
> > > api_cpu_ms usage.
>
> > > However if I try to insert 3 rows or more (again only 1 entity being
> > > inserted), the cpu gets used for more than 1s thereby generating a
> > > warning or error from GAE.
>
> > > Stats from GAE log:
>
> > > For inserting 2 records -> /insert.do 200 77ms 655cpu_ms 643api_cpu_ms
> > > (everything ok)
>
> > > For inserting 3 records -> /insert.do 200 134ms 979cpu_ms
> > > 964api_cpu_ms (yellow warning)
>
> > > For inserting 10 records -> /insert.do 200 178ms 3249cpu_ms
> > > 3216api_cpu_ms (red warning)
>
> > > How to optimize the ‘cpu_ms and api_cpu_ms’ usage? Can GAE perform
> > > only as many operations as 2 inserts into datastore if we want to keep
> > > within the warning levels?
>
> > > Can you please provide some feedback as to whether I am doing anything
> > > wrong in code or have not used a good practice to achieve better
> > > performance. Thanks in advance.
>
> > > Code in servlet (parsing and split operations have been benchmarked
> > > and they are not causing any adverse impact on performance):
>
> > > Pattern p1 = Pattern.compile(","); // created as servlet instance
> > > variable
>
> > > public void doPost(HttpServletRequest req, HttpServletResponse res)
> > > throws ServletException, IOException
> > > {
> > > try {
>
> > > DatastoreService datastore =
> > > DatastoreServiceFactory.getDatastoreService();
> > > List<Entity> entity = new ArrayList<Entity>();
>
> > > for (int i = 0; i < n; i++) {
>
> > > String[] record =
> > > p1.split("1,tester,1.0,1.0,1.0,1.0,1.0,1.0");
>
> > > data1 = Long.parseLong(record[0]);
> > > data2 = record[1];
> > > data3 = Double.parseDouble(record[2]);
> > > data4 = Double.parseDouble(record[3]);
> > > data5 = Double.parseDouble(record[4]);
> > > data6 = Double.parseDouble(record[5]);
> > > data7 = Double.parseDouble(record[6]);
> > > data8 = Float.parseFloat(record[7]);
>
> > > Entity e = new
> > > Entity(DetailsBean.class.getSimpleName());
> > > e.setProperty("column1", i);
> > > e.setProperty("column2", data2);
> > > e.setProperty("column3", i + data3);
> > > e.setProperty("column4", i + data4);
> > > e.setProperty("column5", i + data5);
> > > e.setProperty("column6", i + data6);
> > > e.setProperty("column7", i + data7);
> > > e.setProperty("column8", i + data8);
> > > e.setProperty("crDate", new Date());
> > > e.setProperty("modDate", new Date());
>
> > > entity.add(e);
>
> > > }
>
> > > datastore.put(entity);
>
> > > } catch (Exception e) {
> > > e.printStackTrace();
> > > } finally {
> > > persistenceManager.close();
> > > }
> > > }
>
> > > Entity bean code:
>
> > > package com.pojo;
>
> > > import java.io.Serializable;
> > > import java.util.Date;
> > > import java.util.List;
>
> > > import javax.jdo.annotations.IdGeneratorStrategy;
> > > import javax.jdo.annotations.IdentityType;
> > > import javax.jdo.annotations.NotPersistent;
> > > import javax.jdo.annotations.PersistenceCapable;
> > > import javax.jdo.annotations.Persistent;
> > > import javax.jdo.annotations.PrimaryKey;
>
> > > @PersistenceCapable(identityType = IdentityType.APPLICATION)
> > > public class DetailsBean implements Serializable {
>
> > > private static final long serialVersionUID = 1L;
>
> > > �...@primarykey
> > > �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > > private Long slno;
>
> > > �...@persistent
> > > private long column1;
>
> > > �...@persistent
> > > private String column2;
>
> > > �...@persistent
> > > private double column3;
>
> > > �...@persistent
> > > private double column4;
>
> > > �...@persistent
> > > private double column5;
>
> > > �...@persistent
> > > private float column6;
>
> > > �...@persistent
> > > private double column7;
>
> > > �...@persistent
> > > private double column8;
>
> > > �...@persistent
> > > private Date crDate;
>
> > > �...@persistent
> > > private Date modDate;
>
> > > �...@notpersistent
> > > private String message;
>
> > > �...@notpersistent
> > > private int n;
>
> > > �...@notpersistent
> > > private long offset;
>
> > > �...@notpersistent
> > > private long range;
>
> > > �...@notpersistent
> > > private List data;
>
> > > public DetailsBean() {
>
> > > }
>
> > > public DetailsBean(long v1, String v2, double v3, double v4, double
> > > v5,
> > > float v6,
> > > double v7, double v8) {
> > > this.column1 = v1;
> > > this.column2 = v2;
> > > this.column3 = v3;
> > > this.column4 = v4;
> > > this.column5 = v5;
> > > this.column6 = v6;
> > > this.column7 = v7;
> > > this.column8 = v8;
> > > Date now = new Date();
> > > this.crDate = now;
> > > this.modDate = now;
> > > }
>
> > > public Long getSlno() {
> > > return slno;
> > > }
>
> > > public void setSlno(Long slno) {
> > > this.slno = slno;
> > > }
>
> > > public long getColumn1() {
> > > return column1;
> > > }
>
> > > public void setColumn1(long column1) {
> > > this.column1 = column1;
> > > }
>
> > > public String getColumn2() {
> > > return column2;
> > > }
>
> > > public void setColumn2(String column2) {
> > > this.column2 = column2;
> > > }
>
> > > public double getColumn3() {
> > > return column3;
> > > }
>
> > > public void setColumn3(double column3) {
> > > this.column3 = column3;
> > > }
>
> > > public double getColumn4() {
> > > return column4;
> > > }
>
> > > public void setColumn4(double column4) {
> > > this.column4 = column4;
> > > }
>
> > > public double getColumn5() {
> > > return column5;
> > > }
>
> > > public void setColumn5(double column5) {
> > > this.column5 = column5;
> > > }
>
> > > public float getColumn6() {
> > > return column6;
> > > }
>
> > > public void setColumn6(float column6) {
> > > this.column6 = column6;
> > > }
>
> > > public double getColumn7() {
> > > return column7;
> > > }
>
> > > public void setColumn7(double column7) {
> > > this.column7 = column7;
> > > }
>
> > > public double getColumn8() {
> > > return column8;
> > > }
>
> > >
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---